PivotOJ

Disgruntled Diner

시간 제한: 2000ms메모리 제한: 1024MB출처: BAPC 2024BOJ 32598

문제

Diana is head chef at the Batavian Authentic Prestigious Cuisine. All orders are logged to a central computer, but to organize the kitchen, each ordered item is also printed on a separate ticket. On the back of each ticket, Diana writes the corresponding table number, so servers can easily check where they need to deliver the food. When a ticket is completed, Diana pins it to a board. Of course, there could be duplicate tickets, since a table may order the same item multiple times.

Halfway through service, a disgruntled diner complains: "We have been waiting for hours, but so far we were only served tomato soup! Could you please hurry up?" Diana must address this immediately, since the reputation of the restaurant is at stake! However, in the past, some customers have been dishonest in order to demand expedited service. So, before Diana instructs the kitchen staff, the complaint must be verified.

Since the board is always up-to-date, verification is a matter of checking the relevant tickets. Let tt and mm be the table number and menu item that describe the complaint, respectively. Diana seeks to verify the following claim: "All pinned-up tickets for table tt correspond to menu item mm." In particular, if there are no completed tickets for table tt, Diana considers the claim to be true -- the customer may have misspoken, but they surely deserve extra attention!

Unfortunately, on the board, only one side of each ticket is visible (either the menu item or table number) and Diana does not have time to flip hundreds of tickets. However, by cross-referencing with the central computer, it may be possible to safely ignore certain tickets. Help Diana determine the minimum set of pinned-up tickets that need to be flipped. Or can you (dis)prove the claim without flipping any tickets? You must decide which tickets should be flipped before Diana starts doing so -- she is too strained to make deductions on the fly.

입력

The input consists of:

  • One line with two integers nn and kk (1kn5001 \le k \le n \le 500), the number of orders in the computer and the number of pinned-up tickets.
  • One line with nn strings representing the orders in the computer, each string consisting of one English uppercase letter (the menu item, A-Z) and one digit (the table number, 0-9).
  • One line with kk characters representing the pinned-up tickets, each character being either an English uppercase letter or a digit.
  • One line with a digit tt (0-9) and an English uppercase letter mm (A-Z), specifying the claim: "All pinned-up tickets for table tt correspond to menu item mm."

The pinned-up tickets are guaranteed to correspond to (a subset of) the orders in the computer.

출력

If, without flipping any tickets, the claim is provably true or false, output "true" or "false", respectively. Otherwise, output the minimum number of pinned-up tickets that need to be flipped, followed by their 11-based indices, in any order.

예제

예제 1

입력
6 4
A1 A2 B1 B2 C1 C2
A B 1 2
1 A
출력
2
3 2

예제 2

입력
5 4
A1 B1 C2 C1 A2
2 A B 1
1 A
출력
false

예제 3

입력
4 4
Z0 Z0 F9 F9
Z 0 9 9
4 F
출력
true
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.