// Arup Guha
// 5/8/2018
// Solution to USACO 2015 US Open Bronze Problem: Bessie Gets Even

import java.util.*;
import java.io.*;

public class geteven {

	// I made these lists from these strings: all="BEGIMOS", first="BI", second="GOES", third="M"
	final public static int[] MAP = {1,4,6,8,12,14,18};
	final public static int[][] ITEMS = {{0,3},{1,2,5,6},{4}};

	public static void main(String[] args) throws Exception {

		// Read in data.
		Scanner stdin = new Scanner(new File("geteven.in"));

		int[] odd = new int[26];
		int[] even = new int[26];
		int n = stdin.nextInt();

		// We just need to read in the number of values of each parity for each letter.
		for (int i=0; i<n; i++) {
			char c = stdin.next().charAt(0);
			int val = stdin.nextInt()%2;
			if (val%2 == 0) even[c-'A']++;
			else			odd[c-'A']++;
		}

		// Note that 20^7 bits in an int...barely!
		int res = 0;

		// mask is the setting of each variable to odd or even.
		for (int mask=0; mask<(1<<7); mask++) {

			boolean isEven = false;

			// Go through each bit and xor it for final parity.
			for (int i=0; i<ITEMS.length; i++) {
				int parity = 0;
				for (int j=0; j<ITEMS[i].length; j++)
					parity = (parity ^ ((mask>>ITEMS[i][j])&1));
				if (parity == 0) {
					isEven = true;
					break;
				}
			}

			// We aren't supposed to count these.
			if (!isEven) continue;

			// So, we go through and multiply the number of values at the appropriate parity for each variable.
			int add = 1;
			for (int i=0; i<MAP.length; i++) {
				if (((mask>>i)&1) == 0)
					add *= even[MAP[i]];
				else
					add *= odd[MAP[i]];
			}

			// Add into total.
			res += add;
		}

		// Write result.
		PrintWriter out = new PrintWriter(new FileWriter("geteven.out"));
		out.println(res);
		out.close();
		stdin.close();
	}
}