#include <bits/stdc++.h>
using namespace std;
unsigned long long n, t;
vector<vector<long long> > getmat() {
  vector<vector<long long> > ans(4);
  for (int(i) = (0); (i) < (4); (i)++) ans[i] = vector<long long>(4, 0);
  return ans;
}
vector<vector<long long> > operator*(const vector<vector<long long> >& a,
                                     const vector<vector<long long> >& b) {
  vector<vector<long long> > c = getmat();
  for (int(i) = (0); (i) < (4); (i)++)
    for (int(j) = (0); (j) < (4); (j)++)
      for (int(k) = (0); (k) < (4); (k)++) {
        c[i][j] += a[i][k] * b[k][j];
        c[i][j] %= n;
      }
  return c;
}
vector<vector<long long> > operator+(const vector<vector<long long> >& a,
                                     const vector<vector<long long> >& b) {
  vector<vector<long long> > c = getmat();
  for (int(i) = (0); (i) < (4); (i)++)
    for (int(j) = (0); (j) < (4); (j)++) c[i][j] = (a[i][j] + b[i][j]) % n;
  return c;
}
vector<long long> operator*(const vector<vector<long long> >& a,
                            const vector<long long>& v) {
  vector<long long> ans(4, 0);
  for (int(i) = (0); (i) < (4); (i)++)
    for (int(j) = (0); (j) < (4); (j)++) {
      ans[i] += a[i][j] * v[j];
      ans[i] %= n;
    }
  return ans;
}
vector<long long> operator+(const vector<long long>& v1,
                            const vector<long long>& v2) {
  vector<long long> ans(4, 0);
  for (int(i) = (0); (i) < (4); (i)++) ans[i] = (v1[i] + v2[i]) % n;
  return ans;
}
void show(const vector<vector<long long> >& a) {
  for (int(i) = (0); (i) < (4); (i)++) {
    for (int(j) = (0); (j) < (4); (j)++) {
      cout << a[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}
void show(const vector<long long>& v) {
  for (int(i) = (0); (i) < (4); (i)++) cout << v[i] << " ";
  cout << endl << endl;
}
vector<vector<long long> > pwa[100];
vector<vector<long long> > a;
vector<vector<long long> > id;
vector<vector<long long> > z = getmat();
vector<vector<long long> > binpow(unsigned long long n) {
  vector<vector<long long> > ans = id;
  for (int(b) = (0); (b) < (64); (b)++) {
    if (n & (1ULL << b)) ans = ans * pwa[b];
  }
  return ans;
}
vector<vector<long long> > matsum(unsigned long long n) {
  if (n <= 0) return z;
  if (n == 1) return id;
  vector<vector<long long> > ans = id;
  if (n % 2)
    return matsum(n - 1) + binpow(n - 1);
  else
    return (binpow(n / 2) + id) * matsum(n / 2);
}
vector<long long> shift(unsigned long long t) {
  if (t <= 1) return vector<long long>(4, 0);
  if (t % 2)
    return vector<long long>(4, (t - 1) % n) + (a * shift(t - 1));
  else
    return ((binpow(t / 2) + id) * shift(t / 2)) +
           (matsum(t / 2) * vector<long long>(4, (t / 2) % n));
}
long long mod(long long x) {
  while (x < 0) x += n;
  return x % n;
}
int main() {
  cin >> n;
  a = getmat();
  for (int(i) = (0); (i) < (4); (i)++)
    for (int(j) = (0); (j) < (4); (j)++) a[i][j] = 1;
  a[0][0] = a[1][1] = 2;
  a[0][3] = a[1][2] = a[2][3] = a[3][2] = 0;
  id = getmat();
  for (int(i) = (0); (i) < (4); (i)++) id[i][i] = 1;
  pwa[0] = a;
  for (int(i) = (1); (i) < (80); (i)++) pwa[i] = pwa[i - 1] * pwa[i - 1];
  vector<long long> x(4);
  for (int(i) = (0); (i) < (4); (i)++) cin >> x[i];
  x[0]--;
  x[1]--;
  x[2] = mod(x[2]);
  x[3] = mod(x[3]);
  cin >> t;
  vector<long long> v0 = binpow(t) * x;
  vector<long long> v1 = matsum(t) * vector<long long>(4, 2);
  vector<long long> v2 = shift(t);
  vector<long long> res = v0 + v1 + v2;
  cout << res[0] + 1 << " " << res[1] + 1 << endl;
  return 0;
}
