An arbitrary string of lowercase letters with a length between 1 and 1000.
An integer q (1 ≤ q ≤ 100), representing some quantity or size.
A list of q commands, where each command is either:
- "print a b", with integers 0 ≤ a ≤ b < length of the string
- "reverse a b", with integers 0 ≤ a ≤ b < length of the string
- "replace a b p", with integers 0 ≤ a ≤ b < length of the string and a string p such that (b - a + 1) = length of p

### Example Input:

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

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