#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define MP(x,y) make_pair(x,y)
#define ARRAY 65536
#define X first
#define Y second
#define DBG 0
using namespace std;
 
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
      std::fill( (T*)array, (T*)(array+N), val );
}
 
class Dice{
  //    1  /  rX     4  /
  //  ___/    ->  _____/
  //  2  | 3       2  |  1
  //  |
  //  v rY
  //
  //   0
  //  1   2
  public:
    int value[6];
    int id[6];
    Dice(){
      rep(i,6) id[i] = i;
      rep(i,6) value[i] = i+1;
    }
    int& operator[](int x){return value[id[x]];}
    void swp(int a, int b, int c, int d){
      int tmp = id[a];
      id[a] = id[b];
      id[b] = id[c];
      id[c] = id[d];
      id[d] = tmp;
    }
    void rX(){swp(0, 3, 5, 2);}
    void revX(){rX();rX();rX();}
    void rY(){swp(0, 4, 5, 1);}
    void revY(){rY();rY();rY();}
    void print(){
      rep(i,6)cout << value[id[i]] << ",";
      cout << endl;
    }
};
 
class Stump{
  public:
  int x, y, value;
  Stump(int _x, int _y, int _value):x(_x),y(_y),value(_value){}; 
  void print(){
    cout << "(  " << x<< " , " << y<< " ) " << value << endl;
  }
};
class iStump{
  public:
  int id, val;
  iStump(int _id, int _val):id(_id),val(_val){}; 
};
 
//int mpl[2200][2200] ={0};
 
// ???§??¨????id 31*15??????§
map<pair<int,int>, int> memo;
 
int main(void){
  int n;
  int ca = 0;
  while(cin >> n, n){
    vector<char> paths[ARRAY]; //[state]??????¨???????????????????????????
    int dp[ARRAY] = {0}; //[state]??????¨????????????§???
    int xy[1024][16] = {0}; //[???§??¨?id]???[????????????id] ??? ??????????????????
    int x, y, v;
    int ans = 0;
    int used_xy = 0;
    memo.clear();
 
    string r;
    vector<Stump> ts[32];
    vector<iStump> s[32];
 
    rep(i,n){
      Dice dice;
      cin >> x >> y;
      x+=1050;
      y+=1050;
      cin >> dice[3] >> dice[2] >> dice[1] >> dice[4] >> dice[5] >> dice[0];
      ts[i].push_back(Stump(x, y, dice[5]));
      if(DBG) ts[i].back().print();
 
      cin >> r;
      rep(j,r.size()){
        if( r[j] == 'L'){
          dice.revX();x--;
        }else if(r[j] == 'R'){
          dice.rX();x++;
        }else if(r[j] == 'F'){
          dice.rY();y--;
        }else{
          dice.revY();y++;
        }
        ts[i].push_back(Stump(x, y, dice[5]));
        if(DBG) ts[i].back().print();
      }
 
      map<pair<int,int>, int> used;
      for(int k = ts[i].size()-1; k >= 0 ; --k){
        pair<int,int> xyz=MP(ts[i][k].x,+ts[i][k].y);
        if(used[xyz] != 0) ts[i][k].value = 0;
        if(memo[xyz] == 0){
          //cout << xyz.X << " " << xyz.Y << " " << used_xy << endl;
          memo[xyz] = ++used_xy;
        }
        used[xyz] = 1;
      }
 
 
      int sum = 0;
      //cout << i << endl;
      rep(k,ts[i].size()){
        if(ts[i][k].value > 0){
          int cell_id = memo[MP(ts[i][k].x,ts[i][k].y)];
          s[i].push_back( iStump(cell_id, ts[i][k].value));
          xy[cell_id][i] = ts[i][k].value;
//           cout << cell_id << " -> " << xy[cell_id][i] << endl;
          sum += xy[cell_id][i];
        }
      }
//      cout << "sum " << sum << endl;
    }
//     rep(i, used_xy){
//       rep(j, n){
//         cout << xy[i][j] << "\t";
//       }cout << endl;
//     }
 
    //DP
    rep(i, (1<<n)-1){
      int state = i;
      if(DBG) cout << "baselp " << dp[state] << endl;
      rep(k,n){
        int mask = 1<<k;
        if((state | mask) != state){
          int lp = 0;
          if(DBG)cout << "stump(rev) " << k;
 
          rep(l, s[k].size()){
            iStump ss = s[k][l];
            int current = 0;
 
            for(int j = paths[state].size()-1; j >= 0; --j){
              if(xy[ss.id][paths[state][j]] > 0){
                current = xy[ss.id][paths[state][j]];
                break;
              }
            }
            if(current==0) lp += ss.val;
          }
          if(DBG)cout << " res = " << lp+dp[state] << endl;
          if(dp[state|mask] < lp+dp[state]){
            dp[state|mask] = lp+dp[state];
            //paths[state|mask] = paths[state];
            paths[state|mask].clear();
            paths[state|mask].push_back(k);
            rep(j,paths[state].size()) paths[state|mask].push_back(paths[state][j]);
          }
        }
      }
    }
 
    cout << dp[(1<<n)-1] << endl;
//     cout << "case" << endl;
//     rep(i, paths[(1<<n)-1].size()){
//       cout << paths[(1<<n)-1][i] << endl;
//     }
 
  }
  return 0;
}
 

Measured memory_bytes: 6004