#include <stdio.h>
#include <assert.h>

#define MOD 32749

struct matrix {
    int m[2][2];

    matrix() {
        for (int i=0; i<2; ++i)
            for (int j=0; j<2; ++j)
                m[i][j] = 0;
    }
  
    matrix(int a, int b, int c, int d) {
        m[0][0] = a;
        m[0][1] = b;
        m[1][0] = c;
        m[1][1] = d;
    }
  
    matrix operator*(const matrix& o) const {
        matrix r;
        for (int i=0; i<2; ++i)
            for (int j=0; j<2; ++j)
                for (int k=0; k<2; ++k)
                    r.m[i][j] += m[i][k]*o.m[k][j];
        for (int i=0; i<2; ++i)
            for (int j=0; j<2; ++j)
              r.m[i][j] %= MOD;
        return r;
    }
  
    static matrix identity() {
        matrix r;
        r.m[0][0] = r.m[1][1] = 1;
        return r;
    }
};

matrix pow(matrix b, int e) {
    if (e == 0) return matrix::identity();
    if (e == 1) return b;
    matrix r = pow(b, e/2);
    r = r*r;
    if (e%2) r = r*b;
    return r;
}


int main() {
    FILE *fr, *fw;
    int N, V, E;

#ifdef EVAL
    fr = fopen("input.txt", "r");
    fw = fopen("output.txt", "w");
#else
    fr = stdin;
    fw = stdout;
#endif
    assert(1 == fscanf(fr, "%d", &N));

    matrix b(
      3, 2,
      3, 3
    );
    b = pow(b, N);
    V = b.m[0][0];
    E = b.m[1][0];

    fprintf(fw, "%d %d\n", V, E);
    fclose(fr);
    fclose(fw);
    return 0;
}
