import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.LinkedHashSet; public class Main { static int n, k; static Obj[] arr; public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] sa = br.readLine().split(" "); n = Integer.parseInt(sa[0]); k = Integer.parseInt(sa[1]); sa = br.readLine().split(" "); arr = new Obj[n]; for (int i = 0; i < n; i++) { Obj o = new Obj(); o.p = Integer.parseInt(sa[i]); arr[i] = o; arr[i].next = (i + o.p) % n; } br.close(); for (int i = 0; i < n; i++) { dfs(new LinkedHashSet<>(), i); } PrintWriter pw = new PrintWriter(System.out); for (int i = 0; i < n; i++) { pw.println(dfs2(i, k, 0) + 1); } pw.flush(); } static long dfs2(int x, int r, long d) { if (arr[x].loop != 0) { d += r / arr[x].loop * arr[x].over; r %= arr[x].loop; } if (r > 0) { if (arr[x].next <= x) { return dfs2(arr[x].next, r - 1, d + 1); } else { return dfs2(arr[x].next, r - 1, d); } } else { return d * n + x; } } static void dfs(LinkedHashSet his, int x) { if (arr[x].loop != 0) { return; } if (his.contains(x)) { Integer[] his2 = his.toArray(new Integer[0]); int pre = x; for (int i = his2.length - 1; i >= 0; i--) { arr[x].loop++; if (his2[i] >= pre) { arr[x].over++; } if (his2[i] == x) { break; } pre = his2[i]; } his.remove(x); } his.add(x); dfs(his, arr[x].next); } static class Obj { int p, next; long loop, over; } }