N = int(input()) S = list(str(input())) T = list(str(input())) Q = int(input()) A = set() for i in range(N): if S[i] != T[i]: A.add(i) for _ in range(Q): c,x,y = map(str,input().split()) x = int(x)-1 if c == 'T': T[x] = y else: S[x] = y if S[x] != T[x]: A.add(x) else: A.discard(x) a = list(A)[0] if S[a] > T[a]: print('>') elif S[a] < T[a]: print('<') else: print('=') print(A,S,T)