#include <fstream>
using namespace std;
ifstream cin(“cochilie.in”);
ofstream cout(“cochilie.out”);
int m10011001, fib30, c, lin1, lin2, col1, col2, n, p;
void generare_mat();
void fibo();
void first();
void second();
void generare_mat(){
lin1 = 500, col1 = 500, lin2 = 500, col2 = 501;
m[lin1][col1] = 1, m[lin2][col2] = 2;
for(int i = 3; i <= n; i++){
if(i % 4 1){
for(int col = col1; col <= col2; col++)
m[lin1 - 1][col] = i;
lin1--;
}
else if(i % 4 2){
for(int lin = lin1; lin <= lin2; lin++)
m[lin][col2 + 1] = i;
col2++;
}
else if(i % 4 == 3){
for(int col = col1; col <= col2; col++)
m[lin2 + 1][col] = i;
lin2++;
}
else {
for(int lin = lin1; lin <= lin2; lin++)
m[lin][col1 – 1] = i;
col1—;
}
}
}
void fibo(){
fib1 = fib2 = 1;
for(int i = 3; i <= 29; i++)
fib[i] = fib[i – 1] + fib[i – 2];
}
void first(){
int NRLIN = 0, NRCOL = 0;
for(int i = lin1; i <= lin2; i++)
if(m[i][col1] != m[i-1][col1])
NRLIN += fib[m[i][col1]];
for(int j = col1; j <= col2; j++)
if(m[lin1][j] != m[lin1][j-1])
NRCOL += fib[m[lin1][j]];
cout << NRLIN <<’ ‘<< NRCOL;
}
void second(){
cin >> p;
int slinii = 0;
for(int i = lin1; i <= lin2; i++){
int mini = 100;
for(int j = col1; j <= col2; j++)
mini = min(mini, m[i][j]);
slinii += fib[mini];
if(p <= slinii){
for(int j = col1; j <= col2; j++)
if(m[i][j] != m[i][j-1])
for(int k = 1; k <= fib[m[i][j]]; k++)
cout << m[i][j] << ‘ ‘;
break;
}
}
}
int main(){
cin >> c >> n;
generare_mat();
fibo();
if(c == 1)
first();
else
second();
return 0;
}