#C12803. Filter List

    ID: 42271 Type: Default 1000ms 256MiB

Filter List

Filter List

Given a list of elements and a corresponding list of boolean flags, your task is to filter the list by keeping only the elements whose associated flag is true. In other words, for a given list A and a boolean list B, you are to output the list A' defined by \(A' = \{a_i \mid b_i = \text{true}\}\).

Note: In the input, the boolean values will be represented by 1 (true) and 0 (false).

inputFormat

The input is read from stdin and contains three parts:

  1. An integer \(n\) on the first line representing the number of elements in the list.
  2. A line with \(n\) space-separated elements (these may be numbers or strings).
  3. A line with \(n\) space-separated integers, each being 0 or 1, representing the boolean flags (0 for false, 1 for true) corresponding to each element in the list.

If \(n = 0\), the subsequent lines will be empty.

outputFormat

Print the filtered elements (those with a corresponding flag of 1) to stdout as space-separated values on a single line. If no element satisfies the condition, output an empty line.

## sample
5
a b c d e
0 1 0 1 0
b d