Today the ?Z? city residents enjoy a shell game competition. The residents are gathered on the main square to watch the breath-taking performance. The performer puts 3 non-transparent cups upside down in a row. Then he openly puts a small ball under one of the cups and starts to shuffle the cups around very quickly so that on the whole he makes exactly 3 shuffles. After that the spectators have exactly one attempt to guess in which cup they think the ball is and if the answer is correct they get a prize. Maybe you can try to find the ball too?
The first input line contains an integer from 1 to 3 — index of the cup which covers the ball before the shuffles. The following three lines describe the shuffles. Each description of a shuffle contains two distinct integers from 1 to 3 — indexes of the cups which the performer shuffled this time. The cups are numbered from left to right and are renumbered after each shuffle from left to right again. In other words, the cup on the left always has index 1, the one in the middle — index 2 and the one on the right — index 3.
In the first line output an integer from 1 to 3 — index of the cup which will have the ball after all the shuffles.
1
1 2
2 1
2 1
2
1
2 1
3 1
1 3
2
/* ***********************************************
Author :
Created Time :2015/6/14 19:29:53
File Name :7.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int main()
{
// #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
//#endif
freopen("output.txt","w",stdout);
int a[5];
int n;
while(cin>>n){
cle(a);
a[n]=1;
int x,y;
for(int i=1;i<=3;i++){
cin>>x>>y;
swap(a[x],a[y]);
}
for(int j=1;j<=3;j++){
if(a[j])cout<<j<<endl;
}
}
return 0;
}