An integer q (1 ≤ q ≤ 100), representing some quantity or size.
A string s (1 ≤ length(s) ≤ 1000) consisting of lowercase letters.
A list of q commands, each command can be one of the following:
1. "print a b" where 0 ≤ a ≤ b < length(s)
2. "reverse a b" where 0 ≤ a ≤ b < length(s)
3. "replace a b p" where 0 ≤ a ≤ b < length(s) and b - a + 1 = length(p)

### Example Input:

```
abcde
3
replace 1 3 xyz
reverse 0 2
print 1 4
```

### Function Signature:
Write a function f(s, q, commands) that takes in the input.
def f(s: str, q: int, commands: List[str]):
    '''
    s: a string
    q: an integer
    commands: a list of strings
    '''