import java.util.*; import java.lang.Math; public class ppp { public static void main(String[] args) { MyScanner sc=new MyScanner(); int n=sc.nextInt(); int m=sc.nextInt(); int item1[]=new int[m]; int item2[]=new int[m]; int score[]=new int[m]; for(int i=0;i0){ k*=N; N--; } int b[]=new int[n]; int ans=0; for(int i=0;i B = new ArrayList(); for (int i = 0; i < n; i++) { B.add(base[i]); } k /= n; int N = n - 1; for (int i = 0; i < n - 1; i++) { ans[i] = B.get(x / k); B.remove(x / k); x %= k; k /= N; N--; } ans[n - 1] = B.get(0); } return ans; } } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } }