#include #include #include using namespace std; int n,m; typedef map > M; int q[202020]; queue qu; int main() { while(scanf("%d %d", &n, &m), n!=0 && m!=0) { M inq; memset(q, 0, sizeof(int) * (m+10)); bool ok=true; for(int i=0; i())); inq[a].push(j); qu.push(j); break; } } if(j==m) { ok=false; break; } } if(!ok) { puts("Transportation failed"); } else { while(!qu.empty()) { printf("%d%s", qu.front()+1, qu.size()==1?"\n":" "); qu.pop(); } bool first=true; for(M::iterator i=inq.begin(); i!=inq.end(); i++) { queue &t=i->second; while(!t.empty()) { printf("%s%d", first?"":" ", t.front()+1); t.pop(); first=false; } } puts(""); } } return 0; }