#include <bits/stdc++.h>
using namespace std;
const int maxn = 6;
int mod;
struct Mat {
  int A[maxn][maxn];
  friend Mat operator*(const Mat &a, const Mat &b) {
    Mat ans = {0};
    for (int i = 0; i < maxn; ++i)
      for (int j = 0; j < maxn; ++j)
        for (int k = 0; k < maxn; ++k)
          ans.A[i][j] =
              ((long long)a.A[i][k] * b.A[k][j] % mod + ans.A[i][j]) % mod;
    return ans;
  }
} F = {{{2, 1, 1, 1},
        {1, 2, 1, 1},
        {1, 0, 1},
        {0, 1, 0, 1},
        {1, 1, 1, 1, 1},
        {0, 0, 0, 0, 1, 1}}};
Mat powmod(Mat a, long long n) {
  Mat ans = {0};
  for (int i = 0; i < maxn; ++i) ans.A[i][i] = 1;
  while (n) {
    if (n & 1) ans = ans * a;
    a = a * a;
    n >>= 1;
  }
  return ans;
}
int A[maxn];
long long t;
void init() {
  --A[0], --A[1];
  A[2] = (mod + A[2] % mod) % mod;
  A[3] = (mod + A[3] % mod) % mod;
  A[4] = 2;
  A[5] = 1;
}
void work() {
  Mat ans = powmod(F, t);
  int x = 0, y = 0;
  for (int i = 0; i < maxn; ++i) x = ((long long)A[i] * ans.A[i][0] + x) % mod;
  for (int i = 0; i < maxn; ++i) y = ((long long)A[i] * ans.A[i][1] + y) % mod;
  printf("%d %d\n", x + 1, y + 1);
}
int main() {
  int T;
  while (
      ~scanf("%d%d%d%d%d"
             "%I64d",
             &mod, &A[0], &A[1], &A[2], &A[3], &t)) {
    init();
    work();
  }
  return 0;
}
