#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,m,d,n,x[11],y[11],z[11],k;
int main(){
	cin>>n>>a>>d>>m;
	r(i,m)cin>>x[i]>>y[i]>>z[i];
	cin>>k;
	for(int i=m-1;i>=0;i--){
		if(x[i]){if(y[i]==k)k=z[i];}
		else{
			if(y[i]==k)k=z[i];
			else if(z[i]==k)k=y[i];
		}
	}
	cout<<(k-1)*d+a<<endl;
}