boolean isExist(char[][] matrix, boolean[][] flag, int i, int j, String word) {
		if (word.equals(""))
			return true;
		char x = word.charAt(0);
		word = word.substring(1);
		for (int k = 0; k < 4; k++) {
			int m = i + d[k][0];
			int n = j + d[k][1];
			if (isValid(matrix, m, n) && matrix[m][n] == x && !flag[m][n]) {
				flag[m][n] = true;
				if (isExist(matrix, flag, m, n, word))
					return true;
				flag[m][n] = false;
			}
		}
		return false;
	}