#include using namespace std; using ll = long long; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b A){ ll L = A.size(); FOR(i, 0, L){ if(i) cout << ' '; cout << A[i]; } cout << endl; } ll d[12][12]; int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll X, Y, Z; cin >> X >> Y >> Z; char s0; cin >> s0; ll t0; cin >> t0; char s1; cin >> s1; ll t1; cin >> t1; rep(i, 12){ rep(j, 12){ if(i==j){ d[i][j] = 0; }else{ d[i][j] = inf; } } } d[0][4] = d[4][0] = 1; d[0][8] = d[8][0] = 1; d[4][8] = d[8][4] = 1; d[3][7] = d[7][3] = 1; d[7][11] = d[11][7] = 1; d[3][11] = d[11][3] = 1; d[0][3] = d[3][0] = X-1; d[4][7] = d[7][4] = Y-1; d[8][11] = d[11][8] = Z-1; if(s0==s1){ if(t0>t1) swap(t0, t1); // t0