We are asked to form four-digit numbers using the digits \( 1, 2, 3, 4, 5, 6, 7 \) with all digits distinct.
Step 1: Calculating \( p \), the total number of four-digit numbers
The number of ways to choose the first digit is 7 (since it can be any digit from 1 to 7). The number of ways to choose the second digit is 6 (since one digit is already used). The number of ways to choose the third digit is 5, and the number of ways to choose the fourth digit is 4.
Thus, the total number of numbers is:
\[
p = 7 \times 6 \times 5 \times 4 = 840.
\]
Step 2: Calculating \( q \), the number of numbers greater than 3400
For numbers greater than 3400, the first digit must be 3, 4, 5, 6, or 7.
- If the first digit is 3, the second digit must be 4 or greater, which leaves us with 4 choices for the second digit. The remaining 2 digits can be chosen in \( 5 \times 4 = 20 \) ways. Thus, the number of such numbers is \( 1 \times 4 \times 5 \times 4 = 80 \).
- If the first digit is 4, the second digit can be any of the remaining digits (6 choices), and the third and fourth digits can be chosen in \( 5 \times 4 = 20 \) ways. Thus, the number of such numbers is \( 1 \times 6 \times 5 \times 4 = 120 \).
- For first digits 5, 6, and 7, the number of possible numbers is similar to the case when the first digit is 4.
Thus, the total number of numbers greater than 3400 is:
\[
q = 80 + 120 + 120 + 120 + 120 = 560.
\]
Step 3: Finding the ratio \( p : q \)
The ratio is:
\[
p : q = 840 : 560 = 3 : 2.
\]
Thus, the ratio \( p : q \) is \( 3:2 \).