public:
    int getMinimum(int nextCost, int prevCost, string start, string goal) {
        int n = start.size();
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                if (i!=j && intersects(start[i], goal[i], start[j], goal[j])) {
                    return -1;
                }