import java.io.*;
import java.util.*;
import java.math.*;

public class halfcase_aa {
	public static void main(String[] args) {
		new halfcase_aa().run();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;

	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " is not in bounds: " + x
				+ " not in [" + l + ", " + r + "]");
		return x;
	}

	String FNAME = "halfcase";

	private void solve() throws IOException {
		HashMap<String, HashSet<String>> hm = new HashMap<String, HashSet<String>>();
		int n = inBounds(nextInt(), 1, 1000, "n");
		while (n-- > 0) {
			String s = nextToken();
			String x = s.toLowerCase();
			if (!hm.containsKey(x)) {
				hm.put(x, new HashSet<String>());
			}
			hm.get(x).add(s);
		}
		int m = inBounds(nextInt(), 1, 1000, "m");
		while (m-- > 0) {
			String s = nextToken();
			String x = s.toLowerCase();
			if (!hm.containsKey(x)
					|| (hm.get(x).size() > 1 && !hm.get(x).contains(s))) {
				out.print("-");
			} else {
				out.print("+");
			}
		}
	}
}
