Problem:
Search III

Your task is to write a program of a simple dictionary which implements the following instructions:

insert str: insert a string str in to the dictionary

find str: if the distionary contains str, then print 'yes', otherwise print 'no'

Input

In the first line n, the number of instructions is given. In the following n lines, n instructions are given in the above mentioned format.

Output

Print yes or no for each find instruction in a line.

Constraints

A string consists of 'A', 'C', 'G', or 'T'

1 ≤ length of a string ≤ 12

n ≤ 1000000

Sample Input 1

5
insert A
insert T
insert C
find G
find A

Sample Output 1

no
yes

Sample Input 2

13
insert AAA
insert AAC
insert AGA
insert AGG
insert TTT
find AAA
find CCC
find CCC
insert CCC
find CCC
insert T
find TTT
find T

Sample Output 2

yes
no
no
yes
yes
yes

Notes

Template in C

Solution in JAVA (judge verdict: Runtime Error)

import java.util.Scanner;


public class Main{

	// 要素数は素数を設定
	public static String[] hashTable = new String[50001];

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		int cnt = new Integer(s.nextLine()).intValue();
		for(int i=0 ; i<cnt ; i++) {
			String[] inputData = s.nextLine().split(" ");
			if("insert".equals(inputData[0])) {
				insert(inputData[1]);
			}else {
				find(inputData[1]);
			}
		}
	}

	public static void insert(String value) {
		int hashValue = hashFunction(value);
		// 衝突しない場合、そのまま配列に格納する
		if(hashTable[hashValue] == null || hashTable[hashValue] == "") {
			hashTable[hashValue] = value;
		}
		// 衝突する場合、ハッシュコードに「衝突回数*3」を加算して再ハッシュする
		else {
			aaa :for(int i=1 ; ; i++) {
				hashValue += 1;
				int reHash = hashValue % 50001;
				// リハッシュした場所に格納できる場合、格納して処理を抜ける
				if(hashTable[reHash] == null || hashTable[reHash] == "") {
					hashTable[reHash] = value;
					break aaa;
				}else if(value.equals(hashTable[reHash]))
					break aaa;
				else if(i == 101)
					break aaa;
			}
		}
	}

	public static void find(String value) {
		int hashValue = hashFunction(value);
		if(value.equals(hashTable[hashValue])) {
			System.out.println("yes");
		}else {
			bbb :for(int i=1 ; ; i++) {
				hashValue += 1;
				int reHash = hashValue % 50001;
				if(value.equals(hashTable[reHash])) {
					System.out.println("yes");
					break bbb;
				}
				if(hashTable[reHash] == null) {
					System.out.println("no");
					break bbb;
				}
			}
		}
	}


	public static int hashFunction(String value) {
		int v = 0;
		int p = 5;
		for(int i=0 ; i<value.length() ; i++) {
			if("A".equals(value.substring(i, i+1))) {
				v += 3 * p;
			}else if("C".equals(value.substring(i, i+1))) {
				v += 4 * p;
			}else if("G".equals(value.substring(i, i+1))) {
				v += 5 * p;
			}else if("T".equals(value.substring(i, i+1))) {
				v += 6 * p;
			}
			p *= 5;
		}
		return v % 50001;
	}
}