N = int(input()) S = input() T = input() Q = int(input()) D = N for i in range(N): if S[i] != T[i]: D = i break def review(c, x): global N, S, T, D if c == 'S': if S[x-1] == y: return S = S[0:x-1] + y + S[x:] else: if T[x-1] == y: return T = T[0:x-1] + y + T[x:] if x-1 < D: D = x-1 elif x-1 == D and S[D] == T[D]: for i in range(D+1, N): if S[i] != T[i]: D = i break for _ in range(Q): s = input().split() c, x, y = s[0], int(s[1]), s[2] review(c, x) if D == N: print('-') else: print('>' if S[D] > T[D] else '<')