#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int TEN(int n) {return (n==0)?1:10*TEN(n-1);}


int main() {
    ll fib[31];
    fib[1] = 1;
    fib[2] = 2;
    fib[3] = 4;
    for (int i = 4; i <= 30; i++) {
        fib[i] = fib[i-1]+fib[i-2]+fib[i-3];
    }
    while (true) {
        int t; cin >> t;
        if (!t) break;
        cout << ((fib[t]+9)/10+364)/365 << endl;
    }
    return 0;
}
#include <iostream>
#include <memory.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

const int sz = 100000;
bool prime[sz];

int main(){
  memset(prime, true, sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i = 2; i * i < sz; i++){
    if(prime[i]){
      for(int j = 2; i * j < sz; j++){
	prime[i*j] = false;
      }
    }
  }
  
  int n;
  while(cin >> n && n){
    for(int i = n; i >= 2; i--){
      if(prime[i] && prime[i-2]){
	cout << i - 2 << " " << i << endl;
	break;
      }
    }
  }
  return 0;
}