QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#10991. Colouring

统计

A number from 1 to n is inscribed in each cell of a $2 \times n$ 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.

problem_10991_1.gif

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.

problem_10991_2.gif

How many such colourings exist?

Input Format

The first line of the standard input contains one integer $n$ ($2 ≤ n ≤ 100$). Each of the following two lines contains n integers in the range $[1, n]$, separated by single spaces. The numbers in these lines represent numbers inscribed in consecutive cells of the grid.

Output Format

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

Input

5
1 5 3 1 5
4 2 2 4 3

Output

4

Please note that the example describes the grid from the above figures.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.