#include <stdio.h>
#include <iostream>
#include <string.h>
#include <queue>
#include <algorithm>

using namespace std;

// AOJ 0168
// KannonDou
// input n = year
// EOF = 0


int main(){

	long long a[30] = {1, 2, 4};	//a[0] = 1, a[1] = 2, a[2] = 4??§?????????
									//i+1????????§?????????????????°
	for(int i=3 ; i<30 ; i++){
		a[i] = a[i-1] + a[i-2] + a[i-3];	//a[3]???3-4,2-4,1-4????????????
											//????????°1-4??§2???3?????¢??????????????????1?????????????????????
											//????????????????????????????¨?????????????????????£??????????????????????????§?§£??????
	}
	while(1){
		int n;
		cin >> n;
		if(n==0) return 0;
		int temp = a[n-1];
		temp /= 365;
		temp /= 10;
		cout << temp + 1 << endl;
	}

	return 0;
}
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <map>
#include <set>
#include <cstring>
#include <climits>

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

using namespace std;

bool primearray[10000];

void erathos()
{
	int i;
	memset(primearray, 0, sizeof(primearray));

	REP( i, 2, 10000)
	{
		if( primearray[i] == 0 )
		{
			for( int j = i*2; j < 10000; j+=i)
			{
				primearray[j] = 1;
			}
		}
	}

	return;
}

int main()
{
	int in;

	erathos();

	while( cin >> in, in)
	{
		for( int i = in ; i > 0; i--)
		{
			if( primearray[i] == 0 && primearray[i-2] == 0 )
			{
				cout << i-2 << " " << i << endl;
				break;
			}
		}
	}

	return 0;

}