text: /*numPass=1, numTotal=5
  Verdict:ACCEPTED, Visibility:1, Input:"3
  a
  b
  c
  3", ExpOutput:"aaa
  aab
  aac
  aba
  abb
  abc
  aca
  acb
  acc
  baa
  bab
  bac
  bba
  bbb
  bbc
  bca
  bcb
  bcc
  caa
  cab
  cac
  cba
  cbb
  cbc
  cca
  ccb
  ccc
  ", Output:"aaa
  aab
  aac
  aba
  abb
  abc
  aca
  acb
  acc
  baa
  bab
  bac
  bba
  bbb
  bbc
  bca
  bcb
  bcc
  caa
  cab
  cac
  cba
  cbb
  cbc
  cca
  ccb
  ccc
  "
  Verdict:WRONG_ANSWER, Visibility:1, Input:"1
  a
  0", ExpOutput:"
  ", Output:"hCT
  "
  Verdict:WRONG_ANSWER, Visibility:1, Input:"4
  a
  b
  c
  d
  1", ExpOutput:"a
  b
  c
  d
  ", Output:"aL
  bL
  cL
  dL
  "
  Verdict:WRONG_ANSWER, Visibility:0, Input:"1
  a
  2", ExpOutput:"aa
  ", Output:"aaA
  "
  Verdict:WRONG_ANSWER, Visibility:0, Input:"26
  a
  b
  c
  d
  e
  f
  g
  h
  i
  j
  k
  l
  m
  n
  o
  p
  q
  r
  s
  t
  u
  v
  w
  x
  y
  z
  2", ExpOutput:"aa
  ab
  ac
  ad
  ae
  af
  ag
  ah
  ai
  aj
  ak
  al
  am
  an
  ao
  ap
  aq
  ar
  as
  at
  au
  av
  aw
  ax
  ay
  az
  ba
  bb
  bc
  bd
  be
  bf
  bg
  bh
  bi
  bj
  bk
  bl
  bm
  bn
  bo
  bp
  bq
  br
  bs
  bt
  bu
  bv
  bw
  bx
  by
  bz
  ca
  cb
  cc
  cd
  ce
  cf
  cg
  ch
  ci
  cj
  ck
  cl
  cm
  cn
  co
  cp
  cq
  cr
  cs
  ct
  cu
  cv
  cw
  cx
  cy
  cz
  da
  db
  dc
  dd
  de
  df
  dg
  dh
  di
  dj
  dk
  dl
  dm
  dn
  do
  dp
  dq
  dr
  ds
  dt
  du
  dv
  dw
  dx
  dy
  dz
  ea
  eb
  ec
  ed
  ee
  ef
  eg
  eh
  ei
  ej
  ek
  el
  em
  en
  eo
  ep
  eq
  er
  es
  et
  eu
  ev
  ew
  ex
  ey
  ez
  fa
  fb
  fc
  fd
  fe
  ff
  fg
  fh
  fi
  fj
  fk
  fl
  fm
  fn
  fo
  fp
  fq
  fr
  fs
  ft
  fu
  fv
  fw
  fx
  fy
  fz
  ga
  gb
  gc
  gd
  ge
  gf
  gg
  gh
  gi
  gj
  gk
  gl
  gm
  gn
  go
  gp
  gq
  gr
  gs
  gt
  gu
  gv
  gw
  gx
  gy
  gz
  ha
  hb
  hc
  hd
  he
  hf
  hg
  hh
  hi
  hj
  hk
  hl
  hm
  hn
  ho
  hp
  hq
  hr
  hs
  ht
  hu
  hv
  hw
  hx
  hy
  hz
  ia
  ib
  ic
  id
  ie
  if
  ig
  ih
  ii
  ij
  ik
  il
  im
  in
  io
  ip
  iq
  ir
  is
  it
  iu
  iv
  iw
  ix
  iy
  iz
  ja
  jb
  jc
  jd
  je
  jf
  jg
  jh
  ji
  jj
  jk
  jl
  jm
  jn
  jo
  jp
  jq
  jr
  js
  jt
  ju
  jv
  jw
  jx
  jy
  jz
  ka
  kb
  kc
  kd
  ke
  kf
  kg
  kh
  ki
  kj
  kk
  kl
  km
  kn
  ko
  kp
  kq
  kr
  ks
  kt
  ku
  kv
  kw
  kx
  ky
  kz
  la
  lb
  lc
  ld
  le
  lf
  lg
  lh
  li
  lj
  lk
  ll
  lm
  ln
  lo
  lp
  lq
  lr
  ls
  lt
  lu
  lv
  lw
  lx
  ly
  lz
  ma
  mb
  mc
  md
  me
  mf
  mg
  mh
  mi
  mj
  mk
  ml
  mm
  mn
  mo
  mp
  mq
  mr
  ms
  mt
  mu
  mv
  mw
  mx
  my
  mz
  na
  nb
  nc
  nd
  ne
  nf
  ng
  nh
  ni
  nj
  nk
  nl
  nm
  nn
  no
  np
  nq
  nr
  ns
  nt
  nu
  nv
  nw
  nx
  ny
  nz
  oa
  ob
  oc
  od
  oe
  of
  og
  oh
  oi
  oj
  ok
  ol
  om
  on
  oo
  op
  oq
  or
  os
  ot
  ou
  ov
  ow
  ox
  oy
  oz
  pa
  pb
  pc
  pd
  pe
  pf
  pg
  ph
  pi
  pj
  pk
  pl
  pm
  pn
  po
  pp
  pq
  pr
  ps
  pt
  pu
  pv
  pw
  px
  py
  pz
  qa
  qb
  qc
  qd
  qe
  qf
  qg
  qh
  qi
  qj
  qk
  ql
  qm
  qn
  qo
  qp
  qq
  qr
  qs
  qt
  qu
  qv
  qw
  qx
  qy
  qz
  ra
  rb
  rc
  rd
  re
  rf
  rg
  rh
  ri
  rj
  rk
  rl
  rm
  rn
  ro
  rp
  rq
  rr
  rs
  rt
  ru
  rv
  rw
  rx
  ry
  rz
  sa
  sb
  sc
  sd
  se
  sf
  sg
  sh
  si
  sj
  sk
  sl
  sm
  sn
  so
  sp
  sq
  sr
  ss
  st
  su
  sv
  sw
  sx
  sy
  sz
  ta
  tb
  tc
  td
  te
  tf
  tg
  th
  ti
  tj
  tk
  tl
  tm
  tn
  to
  tp
  tq
  tr
  ts
  tt
  tu
  tv
  tw
  tx
  ty
  tz
  ua
  ub
  uc
  ud
  ue
  uf
  ug
  uh
  ui
  uj
  uk
  ul
  um
  un
  uo
  up
  uq
  ur
  us
  ut
  uu
  uv
  uw
  ux
  uy
  uz
  va
  vb
  vc
  vd
  ve
  vf
  vg
  vh
  vi
  vj
  vk
  vl
  vm
  vn
  vo
  vp
  vq
  vr
  vs
  vt
  vu
  vv
  vw
  vx
  vy
  vz
  wa
  wb
  wc
  wd
  we
  wf
  wg
  wh
  wi
  wj
  wk
  wl
  wm
  wn
  wo
  wp
  wq
  wr
  ws
  wt
  wu
  wv
  ww
  wx
  wy
  wz
  xa
  xb
  xc
  xd
  xe
  xf
  xg
  xh
  xi
  xj
  xk
  xl
  xm
  xn
  xo
  xp
  xq
  xr
  xs
  xt
  xu
  xv
  xw
  xx
  xy
  xz
  ya
  yb
  yc
  yd
  ye
  yf
  yg
  yh
  yi
  yj
  yk
  yl
  ym
  yn
  yo
  yp
  yq
  yr
  ys
  yt
  yu
  yv
  yw
  yx
  yy
  yz
  za
  zb
  zc
  zd
  ze
  zf
  zg
  zh
  zi
  zj
  zk
  zl
  zm
  zn
  zo
  zp
  zq
  zr
  zs
  zt
  zu
  zv
  zw
  zx
  zy
  zz
  ", Output:"aaA
  abA
  acA
  adA
  aeA
  afA
  agA
  ahA
  aiA
  ajA
  akA
  alA
  amA
  anA
  aoA
  apA
  aqA
  arA
  asA
  atA
  auA
  avA
  awA
  axA
  ayA
  azA
  baA
  bbA
  bcA
  bdA
  beA
  bfA
  bgA
  bhA
  biA
  bjA
  bkA
  blA
  bmA
  bnA
  boA
  bpA
  bqA
  brA
  bsA
  btA
  buA
  bvA
  bwA
  bxA
  byA
  bzA
  caA
  cbA
  ccA
  cdA
  ceA
  cfA
  cgA
  chA
  ciA
  cjA
  ckA
  clA
  cmA
  cnA
  coA
  cpA
  cqA
  crA
  csA
  ctA
  cuA
  cvA
  cwA
  cxA
  cyA
  czA
  daA
  dbA
  dcA
  ddA
  deA
  dfA
  dgA
  dhA
  diA
  djA
  dkA
  dlA
  dmA
  dnA
  doA
  dpA
  dqA
  drA
  dsA
  dtA
  duA
  dvA
  dwA
  dxA
  dyA
  dzA
  eaA
  ebA
  ecA
  edA
  eeA
  efA
  egA
  ehA
  eiA
  ejA
  ekA
  elA
  emA
  enA
  eoA
  epA
  eqA
  erA
  esA
  etA
  euA
  evA
  ewA
  exA
  eyA
  ezA
  faA
  fbA
  fcA
  fdA
  feA
  ffA
  fgA
  fhA
  fiA
  fjA
  fkA
  flA
  fmA
  fnA
  foA
  fpA
  fqA
  frA
  fsA
  ftA
  fuA
  fvA
  fwA
  fxA
  fyA
  fzA
  gaA
  gbA
  gcA
  gdA
  geA
  gfA
  ggA
  ghA
  giA
  gjA
  gkA
  glA
  gmA
  gnA
  goA
  gpA
  gqA
  grA
  gsA
  gtA
  guA
  gvA
  gwA
  gxA
  gyA
  gzA
  haA
  hbA
  hcA
  hdA
  heA
  hfA
  hgA
  hhA
  hiA
  hjA
  hkA
  hlA
  hmA
  hnA
  hoA
  hpA
  hqA
  hrA
  hsA
  htA
  huA
  hvA
  hwA
  hxA
  hyA
  hzA
  iaA
  ibA
  icA
  idA
  ieA
  ifA
  igA
  ihA
  iiA
  ijA
  ikA
  ilA
  imA
  inA
  ioA
  ipA
  iqA
  irA
  isA
  itA
  iuA
  ivA
  iwA
  ixA
  iyA
  izA
  jaA
  jbA
  jcA
  jdA
  jeA
  jfA
  jgA
  jhA
  jiA
  jjA
  jkA
  jlA
  jmA
  jnA
  joA
  jpA
  jqA
  jrA
  jsA
  jtA
  juA
  jvA
  jwA
  jxA
  jyA
  jzA
  kaA
  kbA
  kcA
  kdA
  keA
  kfA
  kgA
  khA
  kiA
  kjA
  kkA
  klA
  kmA
  knA
  koA
  kpA
  kqA
  krA
  ksA
  ktA
  kuA
  kvA
  kwA
  kxA
  kyA
  kzA
  laA
  lbA
  lcA
  ldA
  leA
  lfA
  lgA
  lhA
  liA
  ljA
  lkA
  llA
  lmA
  lnA
  loA
  lpA
  lqA
  lrA
  lsA
  ltA
  luA
  lvA
  lwA
  lxA
  lyA
  lzA
  maA
  mbA
  mcA
  mdA
  meA
  mfA
  mgA
  mhA
  miA
  mjA
  mkA
  mlA
  mmA
  mnA
  moA
  mpA
  mqA
  mrA
  msA
  mtA
  muA
  mvA
  mwA
  mxA
  myA
  mzA
  naA
  nbA
  ncA
  ndA
  neA
  nfA
  ngA
  nhA
  niA
  njA
  nkA
  nlA
  nmA
  nnA
  noA
  npA
  nqA
  nrA
  nsA
  ntA
  nuA
  nvA
  nwA
  nxA
  nyA
  nzA
  oaA
  obA
  ocA
  odA
  oeA
  ofA
  ogA
  ohA
  oiA
  ojA
  okA
  olA
  omA
  onA
  ooA
  opA
  oqA
  orA
  osA
  otA
  ouA
  ovA
  owA
  oxA
  oyA
  ozA
  paA
  pbA
  pcA
  pdA
  peA
  pfA
  pgA
  phA
  piA
  pjA
  pkA
  plA
  pmA
  pnA
  poA
  ppA
  pqA
  prA
  psA
  ptA
  puA
  pvA
  pwA
  pxA
  pyA
  pzA
  qaA
  qbA
  qcA
  qdA
  qeA
  qfA
  qgA
  qhA
  qiA
  qjA
  qkA
  qlA
  qmA
  qnA
  qoA
  qpA
  qqA
  qrA
  qsA
  qtA
  quA
  qvA
  qwA
  qxA
  qyA
  qzA
  raA
  rbA
  rcA
  rdA
  reA
  rfA
  rgA
  rhA
  riA
  rjA
  rkA
  rlA
  rmA
  rnA
  roA
  rpA
  rqA
  rrA
  rsA
  rtA
  ruA
  rvA
  rwA
  rxA
  ryA
  rzA
  saA
  sbA
  scA
  sdA
  seA
  sfA
  sgA
  shA
  siA
  sjA
  skA
  slA
  smA
  snA
  soA
  spA
  sqA
  srA
  ssA
  stA
  suA
  svA
  swA
  sxA
  syA
  szA
  taA
  tbA
  tcA
  tdA
  teA
  tfA
  tgA
  thA
  tiA
  tjA
  tkA
  tlA
  tmA
  tnA
  toA
  tpA
  tqA
  trA
  tsA
  ttA
  tuA
  tvA
  twA
  txA
  tyA
  tzA
  uaA
  ubA
  ucA
  udA
  ueA
  ufA
  ugA
  uhA
  uiA
  ujA
  ukA
  ulA
  umA
  unA
  uoA
  upA
  uqA
  urA
  usA
  utA
  uuA
  uvA
  uwA
  uxA
  uyA
  uzA
  vaA
  vbA
  vcA
  vdA
  veA
  vfA
  vgA
  vhA
  viA
  vjA
  vkA
  vlA
  vmA
  vnA
  voA
  vpA
  vqA
  vrA
  vsA
  vtA
  vuA
  vvA
  vwA
  vxA
  vyA
  vzA
  waA
  wbA
  wcA
  wdA
  weA
  wfA
  wgA
  whA
  wiA
  wjA
  wkA
  wlA
  wmA
  wnA
  woA
  wpA
  wqA
  wrA
  wsA
  wtA
  wuA
  wvA
  wwA
  wxA
  wyA
  wzA
  xaA
  xbA
  xcA
  xdA
  xeA
  xfA
  xgA
  xhA
  xiA
  xjA
  xkA
  xlA
  xmA
  xnA
  xoA
  xpA
  xqA
  xrA
  xsA
  xtA
  xuA
  xvA
  xwA
  xxA
  xyA
  xzA
  yaA
  ybA
  ycA
  ydA
  yeA
  yfA
  ygA
  yhA
  yiA
  yjA
  ykA
  ylA
  ymA
  ynA
  yoA
  ypA
  yqA
  yrA
  ysA
  ytA
  yuA
  yvA
  ywA
  yxA
  yyA
  yzA
  zaA
  zbA
  zcA
  zdA
  zeA
  zfA
  zgA
  zhA
  ziA
  zjA
  zkA
  zlA
  zmA
  znA
  zoA
  zpA
  zqA
  zrA
  zsA
  ztA
  zuA
  zvA
  zwA
  zxA
  zyA
  zzA
  "
  */
  #include <stdio.h>
  
  
  void print_string(char str[],char new_str[],int curr_len,int n,int len)
  {
      /*
      str=orignal set,
      new_str=empty char array,
      current_len=0(Intially)
      n=no of elements to be used
      len=the value of p given*/
      if(curr_len==len)//print string when length is equal to p
      {
          printf("%s\n",new_str);
          return;
      }
      else
      {
          int i;
          for(i=0;i<n;i++)
          {
              new_str[curr_len]=str[i];
              print_string(str,new_str,curr_len+1,n,len);
          }
       }
      
      
  }
  
  int main(){
      int n,i,j,m;
      char *c,new[20];
      scanf("%d",&n);
      c=(char*)malloc(n*sizeof(char));
     
      for(i=0;i<n;i++)
     {
         scanf("%c",&c[i]);
         scanf("%c",&c[i]);
     }
      scanf("%d",&m);
      
      
      print_string(c,new,0,n,m);
      
      
  	return 0;
  }