Kabra is a very good friend of JP. So JP has assigned him a task. Given an array, two operations can be performed on it. They are
1) L X : Rotate the array towards left by X.
2) R X : Rotate the array towards right by X.
Now you will be given 2 arrays containing N unique elements. The first one is the inital array(A) and the second one is target array(T).
Also you will be given a list of M operations having ids from 1 to M to be serially performed on it. If after performing any operation the array becomes same as the target array print the id of the operation. If it is not possible print "-1"(without quotes).

Input format:
First line will contain two space separated integers N and M.
Second line will contain N space separated integers Ai denoting the initial array.
Third line will contain N space separated integers Ti denoting the target array.
Next M lines contain the operations of type 1 or 2.

Output format:
Print a single line containing the required answer.

Constraints:
1 ≤ N , M ≤ 10^5
1 ≤ Ai ,  Ti  ≤ 10^9
1 ≤ X ≤ 1000
Note: It is guaranteed that the initial and target arrays are different.
Note: Target array will always be a rotated version of the initial array

SAMPLE INPUT
4 4
2 1 3 4
3 4 2 1
R 1
L 2
L 1
L 5

SAMPLE OUTPUT
3

Explanation

The initial array is 2 1 3 4. Target array is 3 4 2 1.
After the first operation the array becomes 4 2 1 3.
After the second operation it becomes 1 3 4 2.
After the third operation it becomes 3 4 2 1. At this moment the array is equal to the target array hence the answer is 3.
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

n_m = raw_input().split(' ')
n_m = [int(x) for x in n_m]

n = n_m[0]
m = n_m[1]

a = raw_input().split(' ')
a = [int(x) for x in a]

t = raw_input().split(' ')
t = [int(x) for x in t]

#print 'a',a
#print 't',t

first_elem = a[0]

#print first_elem
#print t[0]
curr_idx = 0
target_idx = t.index(first_elem)
#print 'targer_loc',target_loc

ans = -1
if(curr_idx == target_idx):
	ans = 0
for i in range(0,m):
	op = raw_input().split(' ')
	op[1] = int(op[1])
	#print op
	
	if (ans == -1):
		#print curr_idx,op,n
		
		if (op[0]=='R'):
			curr_idx = (curr_idx + op[1])%n
		
		else :
			curr_idx = curr_idx - op[1]
			while(curr_idx<0):
				curr_idx = curr_idx + n
			'''
			if(curr_idx<0):
				x = curr_idx/n + 1
				curr_idx = curr_idx + n*x
			'''
		#print 'curr_idx',curr_idx
		if(curr_idx==target_idx):
			ans = i + 1
#if ans == 0		
print ans