Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him.

The area looks like a strip of cells 1 × n. Each cell contains the direction for the next jump and the length of that jump. Grasshopper starts in the first cell and follows the instructions written on the cells. Grasshopper stops immediately if it jumps out of the strip. Now Artem wants to find out if this will ever happen.


-----Input-----

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — length of the strip. 

Next line contains a string of length n which consists of characters "<" and ">" only, that provide the direction of the jump from the corresponding cell. Next line contains n integers d_{i} (1 ≤ d_{i} ≤ 10^9) — the length of the jump from the i-th cell.


-----Output-----

Print "INFINITE" (without quotes) if grasshopper will continue his jumps forever. Otherwise print "FINITE" (without quotes).


-----Examples-----
Input
2
><
1 2

Output
FINITE

Input
3
>><
2 1 1

Output
INFINITE


-----Note-----

In the first sample grasshopper starts from the first cell and jumps to the right on the next cell. When he is in the second cell he needs to jump two cells left so he will jump out of the strip.

Second sample grasshopper path is 1 - 3 - 2 - 3 - 2 - 3 and so on. The path is infinite.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
class CodeforcesTask641ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.directions = []
		self.jump_lengths = []

	def read_input(self):
		self.n = int(input())
		self.directions = input()
		self.jump_lengths = [int(x) for x in input().split(' ')]

	def process_task(self):
		jumps = 0
		pos = 1
		out = False
		while jumps < self.n * 10 and (not out):
			jumps += 1
			pos += (-1 if self.directions[pos - 1] == '<' else 1) * self.jump_lengths[pos - 1]
			if pos < 1 or pos > self.n:
				out = True
		self.result = 'FINITE' if out else 'INFINITE'

	def get_result(self):
		return self.result
Solution = CodeforcesTask641ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
s = input()
d = list(map(int, input().split()))
k = [False] * n
i = 0
inf = False
while not inf and i >= 0 and (i < n):
	if not k[i]:
		k[i] = True
	else:
		inf = True
	if s[i] == '<':
		i -= d[i]
	else:
		i += d[i]
if inf:
	print('INFINITE')
else:
	print('FINITE')


n = int(input())
s = list(input())
a = list(map(int, input().split()))
f = [0] * n
x = 0
while not f[x]:
	f[x] = 1
	if s[x] == '<':
		x -= a[x]
	else:
		x += a[x]
	if x < 0 or x >= n:
		print('FINITE')
		exit()
print('INFINITE')


n = int(input())
cells = input()
lengths = list(map(int, input().split()))
visited = set()
i = 0
while i not in visited and i < n and (i > -1):
	visited.add(i)
	if cells[i] == '>':
		i += lengths[i]
	else:
		i -= lengths[i]
if i < n and i >= 0:
	print('INFINITE')
else:
	print('FINITE')


n = int(input())
s = input()
d = {}
a = list(map(int, input().split()))
for i in range(n):
	d[i + 1] = 1 * a[i] if s[i] == '>' else -1 * a[i]
cell = 1
for i in range(n):
	cell += d[cell]
	if cell < 1 or cell > n:
		print('FINITE')
		break
else:
	print('INFINITE')


n = int(input())
s = input()
p = 0
k = 0
a = list(map(int, input().split()))
for i in range(2 * n):
	if s[p] == '>':
		p += a[p]
	else:
		p -= a[p]
	if p > n - 1 or p < 0:
		print('FINITE')
		k = 1
		break
if not k:
	print('INFINITE')


n = int(input())
s = input()
l = list(map(int, input().split()))
L = [0 for i in range(n)]
i = 0
while True:
	if L[i] == -1:
		print('INFINITE')
		return
	L[i] = -1
	if s[i] == '>':
		i += l[i]
	else:
		i -= l[i]
	if i <= -1 or i >= n:
		print('FINITE')
		return


n = int(input())
str = input()
inp = list(map(int, input().split()))
for i in range(len(str)):
	if str[i] == '<':
		inp[i] *= -1
visited = [0 for i in range(n)]
cur = 0
while cur >= 0 and cur < n and (visited[cur] != 1):
	visited[cur] = 1
	cur += inp[cur]
if cur >= 0 and cur < n:
	print('INFINITE')
else:
	print('FINITE')


n = int(input())
instructions = list(zip(input(), [int(i) for i in input().split()]))
used = set()
pos = 0
while True:
	if pos < 0 or pos >= n:
		print('FINITE')
		break
	if pos in used:
		print('INFINITE')
		break
	used.add(pos)
	(direct, length) = instructions[pos]
	if direct == '>':
		pos += length
	else:
		pos -= length


Y = lambda : list(map(int, input().split()))
N = lambda : int(input())
n = N()
s = input()
a = Y()
(nxt, ans) = (0, 0)
for i in range(n):
	nxt += a[nxt] if s[nxt] == '>' else -a[nxt]
	if nxt >= n or nxt < 0:
		ans = 2
		break
print('INFINITE'[ans:])


line_length = int(input())
directions = input()
distances = [int(distance) for distance in input().split()]
visited_cells = set()
current_cell = 0
while 0 <= current_cell < line_length:
	if current_cell in visited_cells:
		break
	else:
		visited_cells.add(current_cell)
		if directions[current_cell] == '>':
			current_cell += distances[current_cell]
		else:
			current_cell -= distances[current_cell]
if 0 <= current_cell < line_length:
	print('INFINITE')
else:
	print('FINITE')


(N, Jumber, X, i) = (int(input()), input(), list(map(int, input().split())), 0)
Check = [False] * N
while True:
	if Check[i]:
		print('INFINITE')
		exit()
	Check[i] = True
	if Jumber[i] == '>' and i + X[i] >= N or (Jumber[i] == '<' and i - X[i] < 0):
		print('FINITE')
		exit()
	i += -X[i] if Jumber[i] == '<' else X[i]


def __starting_point():
	n = int(input())
	ins = list(str(input()))
	abi = list(map(int, input().split()))
	sta = [False] * n
	pos = 0
	while True:
		sta[pos] = True
		if ins[pos] == '>':
			pos += abi[pos]
		elif ins[pos] == '<':
			pos -= abi[pos]
		if pos < 0 or pos > n - 1:
			print('FINITE')
			break
		elif sta[pos]:
			print('INFINITE')
			break
__starting_point()


def main():
	n = int(input())
	l = [j - i if c == '<' else j + i for (c, i, j) in zip(input(), list(map(int, input().split())), list(range(n)))]
	(v, i) = ([True] * n, 0)
	while 0 <= i < n:
		if v[i]:
			v[i] = False
		else:
			print('INFINITE')
			return
		i = l[i]
	print('FINITE')

def __starting_point():
	main()
__starting_point()


n = int(input())
t = input()
cord = 0
l = list(map(int, input().split()))
i = 0
d = set({})
while cord < len(t):
	d.add(cord)
	if t[cord] == '>':
		cord = cord + l[cord]
	else:
		cord = cord - l[cord]
	if cord < 0 or cord > n - 1:
		print('FINITE')
		break
	elif cord in d:
		print('INFINITE')
		break


n = int(input())
s = input()
l = list(map(int, input().split()))
count = 0
mas = [False for i in range(n)]
pos = 0
ans = 'INFINITE'
for i in range(n):
	if mas[pos]:
		break
	else:
		mas[pos] = True
	if s[pos] == '<':
		if pos - l[pos] < 0:
			ans = 'FINITE'
		else:
			pos -= l[pos]
	elif pos + l[pos] >= n:
		ans = 'FINITE'
	else:
		pos += l[pos]
print(ans)


n = int(input())
a = input()
count = 0
flag = 0
b = [int(r) for r in input().split()]
i = int()
for i in range(0, n, 1):
	if i == 0:
		if a[i] == '>':
			count = count + b[i]
		else:
			count = count - b[i]
	elif a[count] == '>':
		count += b[count]
	else:
		count -= b[count]
	if count >= n or count < 0:
		flag = 1
		break
if flag == 1:
	print('FINITE')
else:
	print('INFINITE')


(n, s, i) = (int(input()), input(), 0)
d = list(map(int, input().split()))
for _ in range(len(s) + 1):
	if i < 0 or i >= len(s):
		print('FINITE')
		return
	i += [d[i], -d[i]][s[i] == '<']
print('INFINITE')


def main():
	n = int(input())
	arrows = input()
	cells = [int(x) for x in input().split()]
	print(solver(arrows, cells))

def solver(arrows, cells):
	for i in range(len(arrows)):
		if arrows[i] == '<':
			cells[i] = -cells[i]
	visited = [False] * len(cells)
	index = 0
	while True:
		if index >= len(cells) or index < 0:
			return 'FINITE'
		elif visited[index] == True:
			return 'INFINITE'
		else:
			visited[index] = True
			index = index + cells[index]
main()


n = int(input())
a = input()
d = (*map(int, input().split()),)
x = 0
v = [1, -1]
for i in range(n + 1):
	x += v[a[x] == '<'] * d[x]
	if x < 0 or x >= n:
		break
print('IN' * (i >= n) + 'FINITE')


n = int(input())
s = input()
array = list(map(int, input().split()))
visited = [False] * n
c = 0
while 0 <= c < n and (not visited[c]):
	visited[c] = True
	c = c + array[c] * (1 if s[c] == '>' else -1)
if 0 <= c < n:
	print('INFINITE')
else:
	print('FINITE')


n = int(input())
s = input()
a = list(map(int, input().split()))
WAS = False
pos = 1
for i in range(0, n):
	if s[pos - 1] == '<':
		pos -= a[pos - 1]
	else:
		pos += a[pos - 1]
	if pos < 1 or pos > n:
		WAS = True
	if WAS:
		break
if WAS:
	print('FINITE')
else:
	print('INFINITE')


n = int(input())
s = input()
l = list(map(int, input().split()))
x = 1
b = 'INFINITE'
t = 0
for i in range(n):
	if s[x - 1] == '>':
		x += l[x - 1]
		if x > n:
			b = 'FINITE'
			break
	elif s[x - 1] == '<':
		x -= l[x - 1]
		if x <= 0:
			b = 'FINITE'
			break
print(b)


from itertools import count
import os
import sys
from io import BytesIO, IOBase
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = list(input())
a = list(map(int, input().split()))
f = [0] * n
x = 0
while not f[x]:
	f[x] = 1
	if s[x] == '<':
		x -= a[x]
	else:
		x += a[x]
	if x < 0 or x >= n:
		print('FINITE')
		exit()
print('INFINITE')


n = int(input())
s = input()
num = list(map(int, input().split()))
pos = 0
b = [True] * n
while n > pos >= 0 and b[pos]:
	b[pos] = False
	if s[pos] == '>':
		pos += num[pos]
	else:
		pos -= num[pos]
if n > pos >= 0:
	print('INFINITE')
else:
	print('FINITE')


n = int(input())
s = input()
a = list(map(int, input().split()))
k = 0
i = 0
while k < n * 4:
	if s[i] == '>':
		k += a[i]
		i += a[i]
	else:
		k += a[i]
		i -= a[i]
	if i < 0 or i >= n:
		exit(print('FINITE'))
print('INFINITE')


n = int(input())
S = input()
l = list(map(int, input().split()))
i = 0
c = 1
while i >= 0 or i >= n - 1:
	if S[i] == '>' and i + l[i] > n - 1:
		c = 1
		break
	if S[i] == '<' and i - l[i] < 0:
		c = 1
		break
	if l[i] == 0:
		c = 0
		break
	d = l[i]
	l[i] = 0
	if S[i] == '>':
		i = i + d
	else:
		i = i - d
if c == 1:
	print('FINITE')
else:
	print('INFINITE')


n = int(input())
s = list((1 if x == '>' else -1 for x in input()))
l = list(map(int, input().split()))
summ = 1
cur = 0
next = 0
for i in range(n):
	if cur < 0 or cur > n - 1:
		print('FINITE')
		return
	if l[cur] == 0:
		print('INFINITE')
		return
	next += l[cur] * s[cur]
	l[cur] = 0
	cur = next
print('INFINITE' if 0 <= cur < n else 'FINITE')


def solve():
	n = int(input())
	s = input()
	a = list(map(int, input().split()))
	jumps = set([0])
	pos = 0
	for _ in range(n):
		if s[pos] == '<':
			next = pos - a[pos]
		else:
			next = pos + a[pos]
		if next not in range(0, n):
			print('FINITE')
			return
		elif next not in jumps:
			jumps.add(next)
		else:
			print('INFINITE')
			return
		pos = next
solve()


import math

def main_function():
	n = int(input())
	s = input()
	a = [int(i) for i in input().split(' ')]
	current_position = 0
	hash = [0 for i in range(n)]
	while True:
		if current_position < 0 or current_position > n - 1:
			print('FINITE')
			break
		elif hash[current_position] == 1:
			print('INFINITE')
			break
		else:
			hash[current_position] = 1
		if s[current_position] == '>':
			current_position += a[current_position]
		else:
			current_position -= a[current_position]
main_function()


n = int(input())
s = input()
r = lambda : list(map(int, input().split()))
arr = r()
f = True
visited = set()
pos = 0
while 1:
	if pos < 0 or pos >= n:
		break
	if pos in visited:
		f = False
		break
	visited.add(pos)
	if s[pos] == '>':
		pos += arr[pos]
	else:
		pos -= arr[pos]
print('FINITE' if f else 'INFINITE')


n = int(input())
s = input()
l = list(map(int, input().split()))
i = 0
c = 0
while c <= n + 1:
	if s[i] == '>':
		i += l[i]
	else:
		i -= l[i]
	if i < 0 or i >= n:
		n = 0
		break
	c += 1
print('FINITE' if n == 0 else 'INFINITE')


from sys import stdin as Si
from math import floor as F
from collections import defaultdict as dt
from operator import itemgetter as ig

def __starting_point():
	n = int(Si.readline())
	d = Si.readline().strip('\n')
	c = tuple(map(int, Si.readline().split()))
	(tub, i, Exit) = (set([0]), 0, False)
	while not Exit:
		if d[i] == '>':
			i = i + c[i]
		else:
			i = i - c[i]
		if i < 0 or i >= n:
			print('FINITE')
			break
		elif i in tub:
			print('INFINITE')
			break
		else:
			tub.add(i)
__starting_point()


n = int(input())
D = [d if ch == '>' else -d for (ch, d) in zip(input(), map(int, input().split()))]
i = 0
visited = {0}
while True:
	i += D[i]
	if i < 0 or i >= n:
		print('FINITE')
		break
	if i in visited:
		print('INFINITE')
		break
	visited.add(i)


n = int(input())
l = list(input())
m = list(map(int, input().split()))
a = 0
flag = 0
for i in range(n):
	if l[a] == '<':
		a -= m[a]
	else:
		a += m[a]
	if a >= n or a < 0:
		flag = 1
		break
if flag == 1:
	print('FINITE')
else:
	print('INFINITE')


def __starting_point():
	n = int(input())
	d = input()
	w = [int(i) for i in input().split()]
	visited = set()
	i = 0
	while i not in visited and i < n and (i > -1):
		visited.add(i)
		if d[i] == '>':
			i += w[i]
		else:
			i -= w[i]
	if i >= 0 and i < n:
		print('INFINITE')
	else:
		print('FINITE')
__starting_point()


n = int(input())
s = input()
d = list(map(int, input().split()))
i = 0
for _ in range(n + 1):
	if i < 0 or i >= n:
		print('FINITE')
		exit()
	if s[i] == '>':
		i += d[i]
	elif s[i] == '<':
		i -= d[i]
print('INFINITE')


n = int(input())
s = list(map(lambda x: 1 if x == '>' else -1, input().strip()))
d = list(map(int, input().strip().split()))
b = [False for _ in range(n)]
c = 0
while True:
	c += s[c] * d[c]
	if c >= n or c < 0:
		print('FINITE')
		exit()
	if b[c]:
		print('INFINITE')
		exit()
	b[c] = True


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
n = r()
a = input()
b = rl()
visited = defaultdict(bool)
i = 0
ans = True
while True:
	if visited[i]:
		break
	if a[i] == '>':
		dist = i + b[i]
	else:
		dist = i - b[i]
	visited[i] = True
	if dist < 0 or dist >= n:
		ans = False
		break
	i = dist
if not ans:
	print('FINITE')
else:
	print('INFINITE')


n = int(input())
a = list(input())
b = list(map(int, input().split()))
i = 0
flag = False
count = 0
while True:
	if a[i] == '<':
		i = i - b[i]
	else:
		i = i + b[i]
	if i < 0 or i >= n:
		flag = True
		break
	count += 1
	if count > n:
		break
print('FINITE' if flag else 'INFINITE')


class graph:

	def __init__(self, n, v):
		self.G = dict()
		for i in range(1, n + 1):
			self.G.update([(i, set())])
		self.v = v
		self.length = n

	def AppendEdge(self, a):
		self.G[a[0]].add(a[1])
		if not self.v:
			self.G[a[1]].add(a[0])

	def ShowAdjacent(self, a):
		return self.G[a]

	def ShowLength(self):
		return self.length

	def Show(self):
		print(self.G)
n = int(input())
s = input()
f = [int(z) for z in input().split()]
Vis = [0] * n
k = 1
i = 0
Vis[0] = 1
while k != 0:
	if s[i] == '>':
		t = i + f[i]
		if t >= n:
			print('FINITE')
			k = 0
		elif Vis[t]:
			print('INFINITE')
			k = 0
		else:
			Vis[t] = 1
			i = t
	else:
		t = i - f[i]
		if t < 0:
			print('FINITE')
			k = 0
		elif Vis[t]:
			print('INFINITE')
			k = 0
		else:
			Vis[t] = 1
			i = t


def solve(st, x):
	intial = 0
	while 1:
		if intial < 0 or intial >= x:
			return 'FINITE'
		if st[intial][-1] == True:
			return 'INFINITE'
		st[intial][-1] = True
		if st[intial][0] == '>':
			intial += st[intial][-2]
		else:
			intial -= st[intial][-2]
x = int(input())
st1 = list(input())
st2 = list(map(int, input().split()))
st = [[st1[i], st2[i], False] for i in range(x)]
print(solve(st, x))


def main():
	n = int(input())
	d = input()
	l = [int(c) for c in input().split()]
	visited = {0}
	i = 0
	while 0 <= i < n:
		(di, li) = (d[i], l[i])
		i = i + li if di == '>' else i - li
		if i in visited:
			print('INFINITE')
			return
		visited.add(i)
	print('FINITE')

def __starting_point():
	main()
__starting_point()


import sys

def dfs(v):
	used[v] = True
	for i in ed[v]:
		if not used[i]:
			dfs(i)
sys.setrecursionlimit(1000000)
n = int(input())
data1 = input()
data2 = list(map(int, input().split()))
used = [False for i in range(n)]
data3 = [None for i in range(n)]
for i in range(n):
	if data1[i] == '>':
		data3[i] = i + data2[i]
	else:
		data3[i] = i - data2[i]
ans = True
index = 0
prev = -1
for i in range(2 * n):
	used[index] = True
	prev = index
	if data3[index] >= n or data3[index] < 0:
		ans = False
		break
	else:
		index = data3[index]
		if index == prev:
			break
if ans:
	print('INFINITE')
else:
	print('FINITE')


n = int(input())
s = input()
numbers = list(map(int, input().split()))
a = 0
cells = []
condition = False
while True:
	if a < 0 or a >= n:
		print('FINITE')
		break
	if s[a] == '>':
		a += numbers[a]
	else:
		condition = True
		a -= numbers[a]
	if condition and a in cells:
		print('INFINITE')
		break
	cells.append(a)


n = int(input()) - 1
s = input()
d = [int(i) for i in input().split()]
c = True
cnt = 0
i = 0
z = 0
while i <= n and i >= 0:
	if s[i]:
		if s[i] == '>':
			i += d[i]
			z += 1
		elif s[i] == '<':
			i -= d[i]
			z += 1
	else:
		break
	if z >= 2 * n:
		c = False
		break
if i > n or i < 0:
	print('FINITE')
else:
	print('INFINITE')


n = int(input())
way = list(input())
daf = list(map(int, input().split()))
visit = {0}
pos = 0
dest = 0
while True:
	jump = daf[pos]
	if way[pos] == '<':
		dest = pos - jump
	else:
		dest = pos + jump
	if dest in visit:
		print('INFINITE')
		break
	if dest < 0 or dest >= n:
		print('FINITE')
		break
	pos = dest
	visit.add(dest)


n = int(input())
s = input()
a = len(s)
j = list(map(int, input().split()))
x = 1
b = 'INFINITE'
tmp = 0
while tmp < n:
	if s[x - 1] == '>':
		x += j[x - 1]
		if x > n:
			b = 'FINITE'
			break
	elif s[x - 1] == '<':
		x -= j[x - 1]
		if x <= 0:
			b = 'FINITE'
			break
	tmp += 1
print(b)


n = int(input())
s = input()
arr = list(map(int, input().split()))
seen = set()
current_index = 0
while True:
	command = s[current_index]
	step = arr[current_index]
	if command == '>':
		current_index += step
	else:
		current_index -= step
	if current_index > n - 1 or current_index < 0:
		print('FINITE')
		exit()
	elif current_index in seen:
		print('INFINITE')
		exit()
	seen.add(current_index)


n = int(input())
s = input()
a = list(map(int, input().split()))
f = n * [False]
(i, j) = (0, 0)
while True:
	if i < 0 or i >= n or n == 1:
		print('FINITE')
		break
	elif f[i] == True:
		print('INFINITE')
		break
	else:
		f[i] = True
		if s[i] == '>':
			i += a[i]
		else:
			i -= a[i]


n = int(input())
d = input()
u = list(map(int, input().split()))
f = [0 for i in range(n)]
i = 0
while True:
	f[i] = 1
	if d[i] == '<':
		i = i - u[i]
	elif d[i] == '>':
		i = i + u[i]
	if i < 0 or i >= n:
		print('FINITE')
		break
	if f[i] == 1:
		print('INFINITE')
		break


n = int(input())
dir = input()
step = list(map(int, input().split()))
k = 0
i = 0
while True:
	if dir[i] == '>':
		i += step[i]
		k += 1
	else:
		i -= step[i]
		k += 1
	if i < 0 or i > n - 1:
		print('FINITE')
		break
	if k > n:
		print('INFINITE')
		break


(n, s) = (int(input()), input())
a = [int(i) for i in input().split()]
c = i = 0
while True:
	if s[i] == '>':
		i += a[i]
	else:
		i -= a[i]
	if i < 0 or i >= n:
		print('FINITE')
		return
	c += 1
	if c > n:
		print('INFINITE')
		return


di = {'>': 1, '<': -1}
vis = set()
vis.add(0)
si = int(input())
path = input()
(mag, jmp) = (list(map(int, input().split())), 0)
while 1:
	jmp += di[path[jmp]] * mag[jmp]
	if jmp < 0 or jmp >= si:
		break
	if jmp in vis:
		break
	vis.add(jmp)
print('INFINITE' if jmp in vis else 'FINITE')


def main():
	m = int(input())
	jumps = input()
	vals = [int(v) for v in input().split()]
	visited = set()
	cur = 0
	visited.add(cur)
	is_ok = True
	while len(vals) > cur >= 0:
		diff_sign = 1 if jumps[cur] == '>' else -1
		diff = diff_sign * vals[cur]
		cur = cur + diff
		if cur in visited:
			is_ok = False
			break
		visited.add(cur)
	print('FINITE' if is_ok else 'INFINITE')
main()