1 #include <iostream>
2 #include <stack>
3 using namespace std;
4
5 const int MAX = 105;
6
7 typedef struct node_
8 {
9 int updown;//up为1,down为0
10 int id;
11 }N;
12
13 void dealOpe(int n, stack<N> S[], char ope[], N ans[], int &cnt)
14 {
15 int l = 0, r = n - 1;
16 for(int i = 0; i < n - 1; i++)
17 {
18 if(ope[i] == 'L')
19 {
20 while(!S[l].empty())
21 {
22 N t;
23 t.id = S[l].top().id;
24 t.updown = S[l].top().updown ^ 1;
25 S[l + 1].push(t);
26 S[l].pop();
27 }
28 l++;
29 }
30 else
31 {
32 while(!S[r].empty())
33 {
34 N t;
35 t.id = S[r].top().id;
36 t.updown = S[r].top().updown ^ 1;
37 S[r - 1].push(t);
38 S[r].pop();
39 }
40 r--;
41 }
42 }
43 while(!S[r].empty())
44 {
45 N tmp;
46 tmp.id = S[r].top().id;
47 tmp.updown = S[r].top().updown;
48 ans[cnt++] = tmp;
49 S[r].pop();
50 }
51 return ;
52 }
53
54 void output(int cnt, N ans[], int m, int arr[], int &cas_c)
55 {
56 printf("Pile %d\n", cas_c++);
57 for(int i = 0; i < m; i++)
58 {
59 printf("Card %d is a", arr[i] + 1);
60 if(ans[arr[i]].updown == 1)
61 printf(" face up");
62 else
63 printf(" face down");
64 printf(" %d.\n", ans[arr[i]].id);
65 }
66 return ;
67 }
68
69 int main(void)
70 {
71 #ifndef ONLINE_JUDGE
72 freopen("in.txt", "r", stdin);
73 #endif
74 int n, cas_c = 1;
75 while(scanf("%d", &n), n)
76 {
77 char updown[MAX], ope[MAX];
78 scanf("%s %s", updown, ope);
79 N temp;
80 stack<N> S[MAX];
81 for(int i = 0; i < n; i++)
82 {
83 temp.id = i + 1;
84 if(updown[i] == 'U')
85 temp.updown = 1;
86 else
87 temp.updown = 0;
88 S[i].push(temp);
89 }
90 N ans[MAX];
91 int cnt = 0;
92 dealOpe(n, S, ope, ans, cnt);
93
94 int m, arr[MAX];
95 scanf("%d", &m);
96 for(int i = 0; i < m; i++)
97 {
98 int t;
99 scanf("%d", &t);
100 t--, arr[i] = t;
101 }
102 output(cnt, ans, m, arr, cas_c);
103 }
104 return 0;
105 }