```
FUNCTION print_pattern(first_row, num_rows)
# Define the pattern sequence
pattern = [
[7, 8, 9, 1, 2, 3, 4],
[4, 3, 2, 1, 9, 8],
[8, 9, 1, 2, 3],
[3, 2, 1, 9],
[9, 1, 2],
[2, 1, 9],
[9, 1, 2, 3],
[3, 2, 1, 9, 8],
[8, 9, 1, 2, 3, 4],
[4, 3, 2, 1, 9, 8, 7]
]
index = 0
FOR i = 1 TO num_rows
# Print current pattern row
PRINT join(pattern[index], " ")
# Move to next row, wrap around if necessary
index = (index + 1) MOD LENGTH(pattern)
END FOR
END FUNCTION
# Main program
PRINT "Enter the desired number of rows: "
INPUT num_rows
first_row = [7, 8, 9, 1, 2, 3, 4]
CALL print_pattern(first_row, num_rows)
```