A number from to is inscribed in each cell of a grid
in such a way that each number appears exactly twice in the grid and each column contains
two different numbers.
An example of such a configuration is depicted below.
We would like to colour each of the cells white or gray in such a way that
cells located in the same column receive different colours and cells
containing same number receive different colours.
An example of such a colouring of the grid from the previous figure
is depicted below.
How many such colourings exist?
Input
The first line of the standard input contains one integer
().
Each of the following two lines contains integers in the range
, separated by single spaces.
The numbers in these lines represent numbers inscribed in consecutive
cells of the grid.
Output
The first and only line of the standard output should contain a single
integer - the number of different colourings of the grid with two colours
that fulfill the described conditions.
Example
For the input data:
5
1 5 3 1 5
4 2 2 4 3
the correct result is:
4
Please note that the example describes the grid from the above figures.
Task author: Krzysztof Diks.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.