#include <bits/stdtr1c++.h>
using namespace std;

typedef long long ll;
typedef pair<int,bool> pib;
typedef list<pib> vp;

int main() {
  ios::sync_with_stdio(0);
  int n, t = 1;
  while (cin >> n && n) {
    cout << "Pile " << t++ << "\n";
    string s, f; cin >> s >> f;
    list<vp> v;
    for (int i = 0; i < n; i++) {
      vp V;
      if (s[i] == 'U')
        V.push_back(make_pair(i+1,1));
      else
        V.push_back(make_pair(i+1,0));
      v.push_back(V);
    }
    for (int i = 0; i < n-1; i++) {
      if (f[i] == 'R') {
        list<vp>::iterator it = v.end(), it2 = it;
        --it; --it; --it2;
        for (vp::iterator it3 = it2->begin(); it3 != it2->end(); it3++) {
          it->push_front(*it3);
          it->begin()->second ^= 1;
        }
        v.erase(it2);
      }
      else {
        list<vp>::iterator it = v.begin(), it2 = it;
        ++it;
        for (vp::iterator it3 = it2->begin(); it3 != it2->end(); it3++) {
          it->push_front(*it3);
          it->begin()->second ^= 1;
        }
        v.erase(it2);
      }
    }
    vector<pib> V;
    for (pib p : v.front())
      V.push_back(p);
    int m; cin >> m;
    for (int i = 0; i < m; i++) {
      int q; cin >> q;
      --q;
      cout << "Card " << q+1 << " is a face " << (V[q].second ? "up " : "down ") << V[q].first << ".\n";
    }
  }
  return 0;
}