아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Bokstavstärningar

면접 대비

시간 제한1초메모리 제한1024 MB

요약
각각 K개의 글자가 적힌 N개의 주사위가 있을 때, 주어진 단어 목록 중 주사위를 순서대로 배치해 만들 수 있는 단어의 수를 센다.
난이도

보통10점 중 6점

유형
해시맵, 문자열, 조합론
정답자
아직 제출이 없습니다

문제

Klara has NN dices with letters written on them. Each die has a letter on each of its KK sides. By throwing the dice and rearranging them in some arbitrary order, you can make construct a word with NN letters.

Write a program to count the number of valid words that can be constructed using Klara's dice. You will get a wordlist, that contains all the MM valid NN-letter words.

Figure 1: An illustration of the first example. Since K=3K = 3, each die has three sides. You can also write STOL and MASK, but not NATT or KOST.

입력

The first line of input contains three space-separated integers NN, KK and MM.

The next NN lines each describe a die. Line ii will contain KK letters, the letters on the sides of the ii:th die.

Finally, there will be MM lines, the valid words. Each line will contain an NN-letter word.

All words will only capital letters A-Z.

No letter will appear on more than one side of a die.

출력

Your program should print a single integer: the number of valid words that can be written.

예제1

  1. 예제 1

    입력
    4 3 5
    TSU
    NKT
    KMO
    LJA
    KATT
    NATT
    STOL
    MASK
    KOST
    
    예상 출력
    3