#include <bits/stdc++.h>
using namespace std;
const int M = 6;
int n;
long long t;
struct Matrix {
  int a[M][M];
  Matrix() { memset(a, 0, sizeof(a)); }
  inline Matrix operator*(const Matrix& b) const {
    Matrix c;
    for (int i = 0; i < M; i++) {
      for (int k = 0; k < M; k++) {
        if (a[i][k])
          for (int j = 0; j < M; j++) {
            if (b.a[k][j])
              c.a[i][j] =
                  ((c.a[i][j] + (long long)a[i][k] * b.a[k][j]) % n + n) % n;
          }
      }
    }
    return c;
  }
};
int main() {
  Matrix f, base;
  cin >> n;
  for (int i = 0; i < M - 2; i++) scanf("%d", &f.a[0][i]);
  cin >> t;
  f.a[0][0]--;
  f.a[0][1]--;
  f.a[0][4] = 0;
  f.a[0][5] = 1;
  int tmp[M][M] = {{2, 1, 1, 1}, {1, 2, 1, 1},    {1, 0, 1, 0},
                   {0, 1, 0, 1}, {1, 1, 1, 1, 1}, {2, 2, 2, 2, 1, 1}};
  memcpy(base.a, tmp, sizeof(tmp));
  for (; t; t >>= 1) {
    if (t & 1) f = f * base;
    base = base * base;
  }
  cout << f.a[0][0] + 1 << " " << f.a[0][1] + 1 << endl;
}
