#pragma GCC diagnostic warning "-Wextra" #pragma GCC diagnostic warning "-Wshadow" #include using namespace std; #include #include using namespace boost::multiprecision; using bint = cpp_int; using bdec = cpp_dec_float_100; // using bdec = number>; template bool cmin(A& a, B b) { return a > b && (a = b, true); } template bool cmax(A& a, B b) { return a < b && (a = b, true); } template ostream& operator<<(ostream& os, pair& p) { return os << '(' << p.first << ", " << p.second << ')'; } static bool debug = false; void dump() {} template void dump(A&& a, B&&... b) { if (debug) cout << a << (sizeof...(b) ? ' ' : '\n'), dump(b...); } template void dump1D(A& a) { if (debug) for (auto i = a.begin(); i != a.end(); i++) cout << *i << (next(i) != a.end() ? ' ' : '\n'); } template void dump2D(A& a) { if (debug) for (auto i = a.begin(); i != a.end(); i++) dump1D(*i), cout << (next(i) != a.end() ? "" : "\n"); } signed main() { cin.tie(nullptr)->sync_with_stdio(false); // debug = true; int N; cin >> N; string S, T; cin >> S >> T; int Q; cin >> Q; vector> V(Q); for (int i = 0; i < Q; i++) { char a; int b, c; cin >> a >> b >> c; V.at(i) = {a, b, c}; } while (S.front() == '0') S.erase(S.begin()); if ((int)S.size() == 0) S = "0"; while (T.front() == '0') T.erase(T.begin()); if ((int)T.size() == 0) T = "0"; bint L(S); bint R(T); auto f = [&](auto n, auto a, auto b) { bint tmp = pow((bint)10, N - a); bint m = n / tmp % 10; n -= tmp * m; n += tmp * b; dump(make_pair("n", n), make_pair("tmp", tmp), make_pair("m", m)); return n; }; for (const auto& [a, b, c] : V) { if (a == 'S') L = f(L, b, c); else R = f(R, b, c); dump(make_pair("L", L), make_pair("R", R)); cout << ((L > R) ? '>' : (L < R) ? '<' : '=') << '\n'; } }