#include<cstdio>
#include<algorithm>
using namespace std;
#define NMAX 32
unsigned long long P[]={ 1, 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256 , 512 , 1024 , 2048 , 4096 , 8192 , 16384 , 32768 , 65536 , 131072 , 262144 , 524288 , 1048576 , 2097152 , 4194304 , 8388608 , 16777216 , 33554432 , 67108864 , 134217728 , 268435456 , 536870912 , 1073741824 , 2147483648 , 4294967296 };
pair< unsigned long long, int > A[NMAX];
unsigned long long SOL[NMAX];
int I[NMAX];
inline bool cmp(const int a,const int b)
{
return A[a].first > A[b].first;
}
int main()
{
freopen("shop.in","r",stdin);
freopen("shop.out","w",stdout);
long long N,C,ANS=0;
unsigned long long L;
scanf("%lld%lld%lld\n",&N,&C,&L);
int i,a1,a2;
for(i=1; i<=N; ++i)
{
scanf("%d%d\n",&a1,&a2);
A[i].first=P[a1];
A[i].second=a2;
I[i]=i;
}
sort( I+1, I+1+N, cmp );
i=1;
while( L && i<=N )
{
a1=I[i];
if( A[a1].first > L || !A[a1].second )
++i;
else
{
L-=A[a1].first;
++SOL[ a1 ];--A[a1].second;
++ANS;
}
}
printf("%lld\n",ANS);
for(i=1; i<=N; ++i)
printf("%lld ",SOL[i]);
printf("\n");
return 0;
}