Premium problem82. Concatenate with Hierarchical Keys

Medium Locked

Stack df1 on top of df2 into one DataFrame with a two-level row index: an outer level labeling which original DataFrame each row came from ("first" for df1's rows, "second" for df2's rows) and an inner level keeping each row's original index value.

Input

df1 =
  name  score
0    A      1
1    B      2
df2 =
  name  score
0    C      3
1    D      4

Output

         name  score
first  0    A      1
       1    B      2
second 0    C      3
       1    D      4

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)