루미 알고리즘

#1564골드Braille Addition

PO 2023 온라인 예선코딩출제 Joakim Blikstad영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

To save on electricity bills, Lydia has decided to do math without lighting. Without lighting, it is difficult to distinguish regular text, so Lydia plans to switch to Braille. In Braille, each character is written as a grid of 3 × 2 dots, where some are raised. In Figure 1, you can see how the ten digits are written in Braille.

(그림은 원문 저장소에서 볼 수 있습니다)

Figure 1: The Braille digits 0 to 9. The raised dots are indicated by a filled circle.

She now needs your help to verify her calculations. Write a program that finds the sum of two numbers in Braille form.

Input

The first line contains an integer N (1 ≤ N ≤ 9), the number of digits in the first number.

The following three lines contain N Braille digits representing the first number.

The next line contains an integer M (1 ≤ M ≤ 9), the number of digits in the second number.

The following three lines contain M Braille digits representing the second number.

The Braille digits are given as a matrix of 3 × 2 characters, where an asterisk ('*') indicates a raised dot and a period ('.') indicates a dot that is not raised.

The digits are given in the same order as a regular decimal number, so that the last digit corresponds to the unit digit of the number. The numbers have no leading zeros, except in the case the number is 0.

Output

Print sum of the two numbers in braille.

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

GroupPointsConstraints
131Only the braille digit 1 appears in the input.
269No additional constraints.

Explanation of samples

The first number consists of the Braille digits 1, 6, and 0, which together form the number 160. The second number consists of the Braille digits 1 and 6, which together form the number 16. The sum is 160 + 16 = 176.

예제

예제 1

입력
3
*. ** .*
.. *. **
.. .. ..
2
*. **
.. *.
.. ..
출력
*. ** **
.. ** *.
.. .. ..

예제 2

입력
1
**
**
..
1
**
..
..
출력
*. .*
.. **
.. ..

예제 3

입력
1
.*
**
..
1
.*
**
..
출력
.*
**
..

출처 표기

출처: Programmeringsolympiaden 2023년 온라인 예선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.