IITKESO207PA5Q1 - Dynamic Network

Abhishek is a new engineer who is incharge of the local computer network. A network (for us) is a set of PCs (named 1 to n) which can be connected to one another by Abhishek. There are 4 operations that Abhishek can perform: (we shall use the terms PC and node interchangably, they mean the same thing)

addnode x : This adds a PC named x to the network (x is an integer)

delnode x : This removes the PC named x from the network (x is again an integer)

addlink x y : This adds a link between nodes x and y. After adding this link, x is said to be connected to y and also y is said to be connected to x. The connection is symmetric. (x, y are integers)

remlink x y : This removes the link between x and y. After this operation, PCs x and y are said to be disconnected from one another. (x, y are integers)

Note that when a node is deleted, all of it's links to other nodes are removed.

Initially, the network contains no nodes and no connections. Abhishek dilligently starts adding and deleting nodes and connections. After he is done, his boss gives him a list of k PCs are asks him to report their neighbourhood. The neighbourhood of a PC x is defined as follows:

If x is a part of the network, then neighbourhood of x is a list of nodes that are connected to x. Abhishek is required to print this list. In case the PC is in network but has no connections, print "no connections".

If x is not a part of the network (i.e., either x was never added or it was deleted after addition) then Abhishek is required to print "not in network"

Abhishek has asked for your help in this task. Be a good friend and help him.

Input

The input consists of just 1 test case.

The first line of input contains two integers n and op. The first integer n denotes the total number of PCs and nop denotes the number of operations performed by Abhishek.

The next op lines contain each of the operations. The first word of each line denoted the operation (addnode, delnode, addlink or remlink). The word is followed by appropriate arguments (PC number for addnode and delnode; connection endpoints for addlink, remlink)

After this, an integer k is given as input. This denotes the number of PCs for which neighbourhood is asked. The following k lines contain a single integer denoting the PC who's neighbourhood is asked.

Output

The output should consist of k lines corresponding to the neighbourhood report of each PC requested.

If the PC has a neighbourhood, then print each the name of each PC in it's neighbourhood (with one space in between two names). The order of printing should be the order in which connections are added.

If the PC is in the network but has no neighbours, print "no connections".

If the PC is not in the network, print "not in network".

Constraints

Abhishek won't be asked to delete nodes and connection that don't exist.

Example

Input:
4 10
addnode 3
addnode 1
addlink 3 1
addnode 2
delnode 3
addnode 4
addnode 3
addlink 1 3
addlink 4 3
delnode 1
4
3
2
1
4
Output:
4
no connections
not in network
3

Added by:Programming Club, IITK
Date:2018-03-26
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.