#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 1e4+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
int dp[MAXN][110];
int fac[110];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    for(int i=1;i<=n;i++)
    {
        cin>>A[i];
        sum += A[i];
    }

    if(sum&1){
        cout<<0<<"\n";
        return 0;
    }

    dp[0][0] = 1;

    for(int t=1;t<=n;t++){

        cur = A[t];

        for(int i=sum;i>=cur;i--){
            for(int j=t;j>=1;j--){
                dp[i][j] += dp[i-cur][j-1];
                if(dp[i][j]>=PMOD)dp[i][j]-=PMOD;
            }
        }
    }

    fac[0] = 1;

    for(int i=1;i<=n;i++){
        fac[i] = (1LL*i*fac[i-1])%PMOD;
    }

    ll res = 0;
    ll curv;

    for(int i=1;i<n;i++){
        curv = dp[(sum>>1)][i];
        curv = (curv*(ll)fac[i])%PMOD;
        curv = (curv*(ll)fac[n-i])%PMOD;
        res += curv;
        if(res>=PMOD)res-=PMOD;
    }

    cout<<res<<"\n";

    return 0;
}

#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i, a) for (int i = 0; i < (a); i++)
#define repr(i, a) for (int i = (int)(a)-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si()
{
  int x;
  scanf("%d", &x);
  return x;
}
long long sl()
{
  long long x;
  scanf("%lld", &x);
  return x;
}
string ss()
{
  string x;
  cin >> x;
  return x;
}
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint
{
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b)
{
  a.n += b.n;
  if (a.n >= MOD)
    a.n -= MOD;
  return a;
}
mint operator-(mint a, mint b)
{
  a.n -= b.n;
  if (a.n < 0)
    a.n += MOD;
  return a;
}
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5 + 5;
string s;
ll n, result, q;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> s >> q;
  vector<int> t(q), a(q), b(q);
  rep(i, q)
  {
    cin >> t[i] >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<string> str(2);
  int ini = 0;
  str[0] = s.substr(0, n);
  str[1] = s.substr(n, n);
  rep(i, q)
  {
    if (t[i] == 2)
      ini = (ini + 1) % 2;
    else
    {
      if (a[i] < n && b[i] < n)
        swap(str[ini][a[i]], str[ini][b[i]]);
      else if (a[i] < n)
        swap(str[ini][a[i]], str[(ini + 1) % 2][b[i] - n]);
      else if (b[i] < n)
        swap(str[ini][b[i]], str[(ini + 1) % 2][a[i] - n]);
      else
        swap(str[(ini + 1) % 2][a[i] - n], str[(ini + 1) % 2][b[i] - n]);
    }
  }
  cout << str[ini] + str[(ini + 1) % 2] << endl;
}
