1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
using namespace std; 
int main()
{
  int n,z,d,a,p=1,m=0,plus=0,minus=0;
  int i,P[100001]={0};
   cin>>n;
   cin>>z;   
    for( i=1;i<=n;i++) {
       cin>>d;
       cin>>a;
       if(a-d>0){
                 plus+=a-d;
                 P[p]=i;
                 p++;                
               }
       else    {
                 minus+=a-d;
                 P[n-m]=i;
                 m++;              
               }       
     }
    if(z+plus+minus<=0) cout<<"NIE";
    else {
         cout<<"TAK\n";
         for( i=1;i<=n;i++)
            cout<<P[i]<<" ";
         }
    return 0;
}