#B3979. Seven-Segment Display Diagnosis

    ID: 11636 Type: Default 1000ms 256MiB

Seven-Segment Display Diagnosis

Seven-Segment Display Diagnosis

A seven-segment display is an electronic component used for displaying digits. It is composed of seven segments named from \(A\) to \(G\) arranged to form the shape of the digit 8. By turning on different segments, the display can show the digits from \(0\) to \(9\). For example:

  • The digit 0 lights up segments A, B, C, D, E, F (and leaves G off), i.e. \(1111110\).
  • The digit 1 lights up segments B, C, i.e. \(0110000\).
  • The digit 2 lights up segments A, B, D, E, G, i.e. \(1101101\).

However, Dr. X noticed that the seven-segment displays in some traffic lights malfunction. There are two types of faults:

  • Stuck on: A faulty segment always remains lit.
  • Stuck off: A faulty segment always remains unlit.

In normal (fault‐free) operation, each segment behaves according to the standard digit pattern. For a given digit \(d\), let \(p(d)\) be its expected seven-segment pattern (listed below) in the order A B C D E F G:

\( \begin{array}{c|c} \text{Digit} & \text{Pattern} \\ \hline 0 & 1111110 \\ 1 & 0110000 \\ 2 & 1101101 \\ 3 & 1111001 \\ 4 & 0110011 \\ 5 & 1011011 \\ 6 & 1011111 \\ 7 & 1110000 \\ 8 & 1111111 \\ 9 & 1111011 \end{array} \)

Dr. X has recorded a log of the display outputs. Each log record consists of an integer \(d\) (the digit that was intended to be shown) and the observed state of the seven segments as a string of 7 characters (each either 0 or 1), corresponding to segments A through G in that order.

Your task is to deduce, for each segment, which of the following statuses are possible given the log data:

  • normal: the segment functions correctly, i.e. it shows the expected state \(p(d)\) for each digit \(d\).
  • stuck on: the segment is malfunctioning so that it is always lit (i.e. always 1), regardless of the expected state.
  • stuck off: the segment is malfunctioning so that it is always off (i.e. always 0).

For each segment, output a token that lists all the possible statuses (from the above three) that could explain all of the log entries. When a segment has multiple possible statuses, join them with a slash '/' in the following order: normal, stuck on, stuck off. Output the tokens for segments A through G in order, separated by a single space.

Input Format

  • The first line contains a single integer \(N\) (\(1 \leq N \leq 100\)), representing the number of log entries.
  • Each of the next \(N\) lines contains an integer \(d\) (between 0 and 9) and a string of 7 characters (each either 0 or 1), separated by a space.

Output Format

  • Print a single line with 7 tokens. The i-th token corresponds to segment \(A+i-1\) and consists of one or more statuses (among normal, stuck on, stuck off) separated by a slash '/'.

Example

For example, consider the input:

2
1 0110000
7 1110000

Analysis for each segment:

  • Segment A: For digit 1 the expected (normal) state is 0 (observed 0) and for digit 7 it is 1 (observed 1). Only normal is possible.
  • Segment B: Both logs show 1. It could be normal (since digit 1 expects 1 and digit 7 expects 1) or stuck on.
  • Segment C: Similar to B, possible statuses: normal/stuck on.
  • Segment D: In both cases the expected state is 0. So possible statuses: normal/stuck off.
  • Segment E: normal/stuck off.
  • Segment F: normal/stuck off.
  • Segment G: normal/stuck off.

Thus, the output would be:

normal normal/stuck on normal/stuck on normal/stuck off normal/stuck off normal/stuck off normal/stuck off

inputFormat

The input begins with an integer \(N\) (\(1 \le N \le 100\)), followed by \(N\) lines each containing:

  • An integer \(d\) (between 0 and 9), representing the intended digit.
  • A 7-character string of 0s and 1s representing the observed state of segments A to G.

Tokens in a line are separated by a single space.

outputFormat

Output a single line with 7 tokens separated by a space. The i-th token represents the possible statuses for segment A+i-1, joined by '/' in the order: normal, stuck on, stuck off.

sample

2
1 0110000
7 1110000
normal normal/stuck on normal/stuck on normal/stuck off normal/stuck off normal/stuck off normal/stuck off