int noOfJumps = 0;
boolean ready = false;
Position[] fields;

void main() {
    int size = getSizeOfBoard();
    fields = new Position[size * size];
    int row = getRow();
    int col = getColumn();
    setField(0, row, col);
    nextJump(row, col);
    if (ready) {
        printResult();
    }
}

void nextJump(int fromRow, int fromCol) {
    if (isReady()) {
        ready = true;
    }
    Position[] positions = getPossibleJumps(fromRow, fromCol);
    for (int p = 0; p < positions.length; p++) {
        mark(fromRow, fromCol);
        jump(positions[p].row, positions[p].col);
        noOfJumps++;
        setField(noOfJumps, positions[p].row, positions[p].col);
        nextJump(positions[p].row, positions[p].col);
        if (ready) {
            return;
        }
        unmark(fromRow, fromCol);
        noOfJumps--;
        jump(fromRow, fromCol);
    }
}

boolean isReady() {
    int marked = 0;
    int size = getSizeOfBoard();
    for (int r = 0; r < size; r++) {
        for (int c = 0; c < size; c++) {
            if (isMarked(r, c)) {
                marked++;
            }
        }
    }
    return marked == size*size - 1;
}


Position[] getPossibleJumps(int row, int col) {
    Position[] ps = new Position[8];
    int index = 0;
    
    int r = row - 1;
    int c = col - 2;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
      
    r = row - 2;
    c = col - 1;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
        
    r = row - 2;
    c = col + 1;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
           
    r = row - 1;
    c = col + 2;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
                
    r = row + 1;
    c = col + 2;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
            
    r = row + 2;
    c = col + 1;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
            
    r = row + 2;
    c = col - 1;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
            
    r = row + 1;
    c = col - 2;
    if (canJump(r, c)) {
        Position p = new Position();
        p.row = r;
        p.col = c;
        ps[index] = p;
        index++;
    }
    
    Position[] res = new Position[index];
    for (int i = 0; i<res.length; i++) {
        res[i] = ps[i];
    }
    return res;
}

void setField(int index, int row, int col) {
    Position pos = new Position();
    pos.row = row;
    pos.col = col;
    fields[index] = pos;
}

void printResult() {
    for (int i = 0; i <= noOfJumps; i++) {
        System.out.println("Zug " + i + ": (" + fields[i].row + 
            "/" +  fields[i].col + ")");
    }
}

class Position implements java.io.Serializable {
    int row;
    int col;
}

