using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
var Beki2Dict = new Dictionary<int, int>();
Beki2Dict[1] = 2;
Beki2Dict[2] = 4;
Beki2Dict[3] = 8;
Beki2Dict[4] = 16;
Beki2Dict[5] = 32;
Beki2Dict[6] = 64;
Beki2Dict[7] = 128;
int N = int.Parse(Console.ReadLine());
int M = -1;
for (int I = 1; I <= 8; I++) {
if (Beki2Dict[I] >= N) {
M = I;
break;
}
}
Console.WriteLine(M);
// 飲むジュースのリスト[人]なDict
var JuiceListDict = new Dictionary<int, List<int>>();
for (int I = 1; I <= M; I++) {
JuiceListDict[I] = new List<int>();
}
for (int I = 1; I <= N; I++) {
int Bin2Val = I - 1;
string BinStr = Convert.ToString(Bin2Val, 2);
BinStr = BinStr.PadLeft(M, '0');
for (int J = 0; J <= BinStr.Length - 1; J++) {
if (BinStr[J] == '1') {
JuiceListDict[J + 1].Add(I);
}
}
}
foreach (List<int> EachJuiceList in JuiceListDict.Values) {
var AnswerList = new List<int>();
AnswerList.Add(EachJuiceList.Count);
AnswerList.AddRange(EachJuiceList);
Console.WriteLine(IntEnumJoin(" ", AnswerList));
}
string X = Console.ReadLine();
for (int I = 1; I <= N; I++) {
int Bin2Val = I - 1;
string BinStr = Convert.ToString(Bin2Val, 2);
BinStr = BinStr.PadLeft(M, '0');
if (BinStr == X) {
Console.WriteLine(I);
}
}
}
// セパレータとInt型の列挙を引数として、結合したstringを返す
static string IntEnumJoin(string pSeparater, IEnumerable<int> pEnum)
{
string[] StrArr = Array.ConvertAll(pEnum.ToArray(), pX => pX.ToString());
return string.Join(pSeparater, StrArr);
}
}