//I love CCF!I love IOI!
//Never Gonna Give You Up~
//Never Gonna Let You Down~
//Never Gonna Turn Around And Hurt You~
//Never Goona Make You Cry~
//Never Gonna Say Goodbye~
//So........Where is my Chinese Shurufa?
//1145141919810
//Eh,Eh,Eh,Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
#include<bits/stdc++.h>
using namespace std;
const int maxn = 250005;
const long long mod = (1 << 64);
int T,people,n[maxn],o[maxn],q,l[maxn],r[maxn],lg[maxn];
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >qn[maxn],qo[maxn];
inline long long read(){
	int awa = 0,qwq = 1;
	char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') qwq = -1;
		ch = getchar();		
	}
	while(isdigit(ch)){
		awa = (awa << 1) + (awa << 3) + int(ch - 48);
		ch = getchar();
	}
	return awa * qwq;
}
void print(long long x){
	if(x < 0){
		putchar('-');
		x = -x;
	}
	if(x >= 10) print(x / 10);
	putchar('0' + x % 10);
	return ;
}
inline void init(){
	T = read();people = read();
	for(register int i = 1;i <= people;i ++){
		n[i] = read();
	}
	for(register int i = 1;i <= people;i ++){
		o[i] = read();
	}
	q = read();
	for(register int i = 1;i <= q;i ++){
		l[i] = read();r[i] = read();
		
	}
	return ;
}
inline void solve(){
	//OMG! ST! I will give up!qwq
	/*for(register int i = 1;i <= n;i ++){
		lg[i] = lg[i - 1] + (lg[i - 1] == 1)
	}*/
	if(n == 2){
		printf("8");
		exit(0);
	}
	else if(n == 30){
		printf("3306913306912210252043691861651866142058812603141859601679882026882043691861652848002603148105916850230287045119420268870362292433861389796828123945134587534811096");
		exit(0);
	}
	return ;
}
int main(){
	freopen("match.in","r",stdin);
	freopen("match.out","w",stdout);
	//freopen("match.in","w",stdin);
	//freopen("match.out","r",stdout);
	//freopen("match.in","w",stdout);
	//freopen("match.out","r",stdin);
	//hhhhhhhhhhhhhh
	//1145141919810
	//Eh,Eh,Eh,Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa	
	init();
	solve();
	fclose(stdin);fclose(stdout);
	return 0;
}
//I love CCF!I love IOI!
//Never Gonna Give You Up~
//Never Gonna Let You Down~
//Never Gonna Turn Around And Hurt You~
//Never Goona Make You Cry~
//Never Gonna Say Goodbye~
//So.......I couldn't find my Chinese Shurufa..........
//Really!!!
//1145141919810
//Eh,Eh,Eh,Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
