Under construction

Still being built. Things may change

Möbius

Time limit2sMemory limit1024 MB

Summary
Given arrays a and b, count the pairs (a_i, b_j) by the value of the Möbius function of their product, for -1, 0, and 1.
Level

Medium6 of 10

Topics
Number theory, Math, Combinatorics
Solved
No attempts yet

Statement

For any positive integer nn, the Möbius function μ(n)\mu(n) is defined. Its value is in {−1,0,1}\{-1, 0, 1\}, depending on the prime factorization of nn.

  • If xx is a square-free positive integer with an even number of prime factors, then μ(x)=1\mu(x) = 1.
  • If xx is a square-free positive integer with an odd number of prime factors, then μ(x)=−1\mu(x) = -1.
  • If xx is divisible by the square of some prime, then μ(x)=0\mu(x) = 0.

For example, μ(1)=1\mu(1) = 1, μ(2)=−1\mu(2) = -1, μ(6)=1\mu(6) = 1, and μ(12)=0\mu(12) = 0.

You are given two arrays aa and bb of positive integers.

Let kyk_y be the number of pairs (i,j)(i, j) with 1≤i≤n1 \le i \le n and 1≤j≤m1 \le j \le m such that μ(ai⋅bj)=y\mu(a_i \cdot b_j) = y.

Compute k−1k_{-1}, k0k_{0}, and k1k_{1}.

Input

The first line contains two integers nn and mm (1≤n,m≤2⋅1051 \le n, m \le 2 \cdot 10^5), the sizes of arrays aa and bb.

The second line contains nn integers aia_i (1≤ai≤1061 \le a_i \le 10^6) separated by spaces.

The third line contains mm integers bib_i (1≤bi≤1061 \le b_i \le 10^6) separated by spaces.

Output

Print three integers k−1k_{-1}, k0k_{0}, and k1k_{1} separated by spaces on a single line.

Examples1

  1. Example 1

    Input
    6 4
    1 2 3 4 5 6
    2 3 5 7
    
    Expected output
    6 9 9