본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 18884번 New Year and Naming

by 현장 2024. 1. 12.

-Code

n, m = map(int, input().split())
s_list = list(input().split())
t_list = list(input().split())

for _ in range(int(input())):
    year = int(input())
    res = s_list[year % n - 1] + t_list[year % m - 1]
    print(res)