13561356 SUSTech Online Judge
Problem 1356 --[Easy] Clever LowbieH

1356: [Easy] Clever LowbieH

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 597  Solved: 205
[Submit][Status][Web Board]

Description

LowbieH is a naive five-year-old kid. Because he is stupid, his best friend Skylar wants to train him. Skylar gives LowbieH $$n$$ strings containing only lowercase letters, and the $$i_{th}$$ string is $$s_i$$. Skylar raises q problems, and takes out two strings $$s_i$$ and $$s_j$$ at a time, she wants LowbieH to judge $$f(i,j)$$ and $$f(j,i)$$ which is bigger and which is smaller. $$f(s,t)$$ represent the maximum $$i$$ satisfy $$s_{1...i} = t_{|t|-i+1...|t|}$$, and $$f(s,t) = 0$$ if such $$i$$ doesn't exist. For each question, LowbieH will provide a response $$c$$ which is "<", ">" or "=". Now you are the referee, please judge how many questions LowbieH answered correctly.

Input

The first line is the integer $$n$$ $$( 1 \leq n \leq 1000)$$.

The following $$n$$ lines contains one string $$s_i$$ $$1 \leq |s_i| \leq 1000, 1 \leq i \leq n)$$.

The next line is the integer $$q$$ $$(1 \leq q \leq 1000)$$.

The following $$q$$ lines contains $$i, j, c$$ which means Skylar takes out $$s_i$$ and $$s_j$$. LowbieH's answer is $$c$$. $$1 \leq i, j \leq n, c \in (<,>,=))$$.

Output

One line an integer, representing the answer.

Sample Input

2
abcxc
cba
1
1 2 =

Sample Output

1


[Submit][Status]