#include <iostream>
using namespace std;

long long dp[31] = {1,1,2};
int ans[31];
int n;

int main(){
  
  for(int i = 3 ; i < 31 ; i++){
    dp[i] = dp[i-1] + dp[i-2] + dp[i-3];
  }
  for(int i = 0; i < 31 ; i++){
    ans[i] = dp[i] / 10;
    if(dp[i] % 10 != 0) ans[i]++;
    ans[i] = ans[i] / 365 ;
    if(ans[i] % 365 != 0) ans[i]++;
    if(ans[i] == 0) ans[i]++;
  }

  for(int i = 0; i < 31 ; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  for(int i = 0; i < 31 ; i++){
    cout << dp[i] << " ";
  }

  while(cin >> n, n != 0){

    cout << ans[n] << endl; 
  }
  
  return 0;
}