public static boolean validate(Stack<Character> p, char k) {
		Iterator<Character> it = p.iterator();
		ArrayList<Character> list = new ArrayList<Character>();
		;
		while (it.hasNext()) {
			list.add(it.next());
		}
		int index = -1;
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i) == index) {
				index = i;
			}
		}
		if (index == -1) {
			if (p.peek() == 'X')
				return true;
			return false;
		}
		for (int i = index + 1; i < list.size(); i++) {
			if (list.get(i) != 'X')
				return false;
		}
		p.clear();
		for (int i = 0; i < list.size(); i++) {
			if (i != index)
				p.add(list.get(i));
		}
		p.add('m');

		return true;

	}