HashSet<String> find(char[][] matrix, boolean[][] flag, int x, int y,
			StringBuilder sb, TreeNode root) {
		HashSet<String> res = new HashSet<String>();
		if (root.isWord()) {
			res.add(sb.toString());
		}
		for (int k = 0; k < 8; k++) {
			int i = x + d[k][0];
			int j = y + d[k][1];
			if (isValid(matrix, i, j) && root.hasChild(matrix[i][j])
					&& !flag[i][j]) {
				flag[i][j] = true;
				sb.append(matrix[i][j]);
				res.addAll(find(matrix, flag, i, j, sb,
						root.getChild(matrix[i][j])));
				sb.deleteCharAt(sb.length() - 1);
				flag[i][j] = false;
			}
		}
		return res;
	}