Help my maniacal wife decorate our Christmas tree My wife is very, let's say, particular when it comes to putting ornaments on our Christmas tree. Let's get her some code to help her in this trying time.

Input

Given an input 2 &lt; n &lt; 10 the height of the tree and 0 &lt; k &lt; n the distinct number of ornaments.

Task

Decorate the tree starting with 1 and increment to k as we wrap the ornaments around the tree. If we reach k and we have more branches to decorate then start back at 1.

It is okay if there are not the same number of each ornament on the tree, as long as the pattern is satisfied.

The ornaments should appear above each branch ^ except for the top row.

The tree is structured by starting with one branch  then the next level has + 1 branches with a space between each, staggered from the top like:

 ^
^ ^


For a third row you would add one more branch and stagger them again such that no branch is on the same column (if you think of it like a grid).

  ^
 ^ ^
^ ^ ^


Output

Output your decorated tree.

Examples

1.

 n = 3, k = 2 

  ^      //Height is 3
 ^ ^
^ ^ ^


Now we decorate each branch starting with 1 and increment to k:

  ^
 1 2
 ^ ^
1 2 1
^ ^ ^


2.

 n = 6, k = 5 

     ^    //Non-Decorated
    ^ ^
   ^ ^ ^
  ^ ^ ^ ^
 ^ ^ ^ ^ ^
^ ^ ^ ^ ^ ^

     ^    //Decorated
    1 2
    ^ ^
   3 4 5
   ^ ^ ^
  1 2 3 4
  ^ ^ ^ ^
 5 1 2 3 4
 ^ ^ ^ ^ ^
5 1 2 3 4 5
^ ^ ^ ^ ^ ^


3.

n = 5, k = 1 

    ^
   ^ ^
  ^ ^ ^
 ^ ^ ^ ^
^ ^ ^ ^ ^

    ^
   1 1
   ^ ^
  1 1 1
  ^ ^ ^
 1 1 1 1
 ^ ^ ^ ^
1 1 1 1 1
^ ^ ^ ^ ^


This is code-golf so the shortest code wins! Have fun and good luck!
C# 226 221 Bytes
Saved 5 Bytes thanks to @Mukul Kumar and @aloisdg
Golfed:
string C(int n,int k){string o=&quot;&quot;,x;int j=1,i=1,m;for(;i&lt;=n;i++){o+=string.Concat(Enumerable.Repeat(&quot;^ &quot;,i)).PadLeft(n+i)+&quot;\n&quot;;m=0;x=&quot;&quot;;if(i&lt;n){while(m&lt;i+1){if(j&gt;k)j=1;x+=j+++&quot; &quot;;m++;}o+=x.PadLeft(n+i+1)+&quot;\n&quot;;}}return o;}

Ungolfed:
public string C(int n, int k, WifeMode wifeMode = WifeMode.Maniacal)
{
  string o = &quot;&quot;,x;
  int j = 1,i=1,m;

  for (; i &lt;= n; i++)
  {
    o += string.Concat(Enumerable.Repeat(&quot;^ &quot;, i)).PadLeft(n+i) + &quot;\n&quot;;

    m = 0;
    x = &quot;&quot;;

    if (i &lt; n)
    {
      while (m &lt; i + 1)
      {
        if (j &gt; k) j = 1;
        x += j++ + &quot; &quot;;
        m++;
      }

      o += x.PadLeft(n + i + 1) + &quot;\n&quot;;
    }
  }

  return o;
}

Testing:
Console.Write(new ChristmasTreeDecorating().C(20, 9));

                   ^ 
                  1 2 
                  ^ ^ 
                 3 4 5 
                 ^ ^ ^ 
                6 7 8 9 
                ^ ^ ^ ^ 
               1 2 3 4 5 
               ^ ^ ^ ^ ^ 
              6 7 8 9 1 2 
              ^ ^ ^ ^ ^ ^ 
             3 4 5 6 7 8 9 
             ^ ^ ^ ^ ^ ^ ^ 
            1 2 3 4 5 6 7 8 
            ^ ^ ^ ^ ^ ^ ^ ^ 
           9 1 2 3 4 5 6 7 8 
           ^ ^ ^ ^ ^ ^ ^ ^ ^ 
          9 1 2 3 4 5 6 7 8 9 
          ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
         1 2 3 4 5 6 7 8 9 1 2 
         ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
        3 4 5 6 7 8 9 1 2 3 4 5 
        ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
       6 7 8 9 1 2 3 4 5 6 7 8 9 
       ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
      1 2 3 4 5 6 7 8 9 1 2 3 4 5 
      ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ 
     6 7 8 9 1 2 3 4 5 6 7 8 9 1 2 
     ^ ^ ^ ^ ^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