Permission Coverage Report
An access-control system defines exactly 20 permissions, named by the lowercase
letters a through t. The company has n roles. Each role requires a fixed
subset of the 20 permissions — a role is satisfied by a user only if the user
holds every permission the role requires.
You are auditing q users. For each user you know the subset of the 20
permissions they have been granted. For every user, report two numbers:
- Satisfied roles — the number of roles whose entire required permission set is contained in the user's granted permissions (the user could perform that role).
- Unrelated roles — the number of roles whose required permission set shares no permission at all with the user's granted permissions (the role needs nothing the user has).
A role with an empty requirement counts as both satisfied and unrelated for every user, since the empty set is a subset of any set and disjoint from any set. Different roles may require the same set of permissions, and each is counted separately.
Input
The first line contains two integers n and q (1 ≤ n, q ≤ 10^5).
Each of the next n lines describes one role's required permissions, and each
of the next q lines describes one user's granted permissions. Each such line
is either:
-, meaning the empty set, or- a comma-separated list of distinct letters from
atot(in any order), each appearing at most once, meaning the set of those permissions.
A line never contains spaces, and every letter on it lies between a and t.
Output
Print q lines. The i-th line contains two integers: the number of roles
satisfied by the i-th user, followed by the number of roles unrelated to the
i-th user.
Notes
In the first example, permissions are letters among a..t. A role
requiring a,b is satisfied by a user granted a,b,c (superset), and is
unrelated to a user granted only d (no overlap), but is neither satisfied
nor unrelated to a user granted only a (partial overlap).