Macarons in La Fête

La Fête de la Musique is an international celebration that takes place on June 21, its aim is to promote music in two ways: The first that amateur musicians voluntarily go out to play in the street. The second is with the organization of free concerts, in which the public has the opportunity to witness their favorite artists regardless of style or origin. Pierre is an excellent confiseur who knows about the popularity of this festival so he wants to take advantage of it and sell some deserts. For this year’s festival Pierre plans to sell his delicious Macarons. Macarons are sweet meringue-based confection made with egg white, icing sugar, granulated sugar, almond powder or ground almond, and food colouring. Macarons come in different flavors and types and Pierre has mastered two types of them: Traditional Macarons and Glazed Macarons. For the festival Pierre will bake n trays of Macarons each tray of an unique flavour containing up to m Macarons. Each one of this trays will be of traditionals Macarons or glazed Macarons, but as everybody knows Macarons are very difficult to make and glazed Macarons are even worst and Pierre doesn’t want to work more unnecessarily. Pierre already knows the preferences of his m clients and he wants to make them all happy. Pierre’s clients will be happy if for each client he prepares at least one of his favourites Macarons. Each client has a list of favorites Macaron’s flavours, and at most 1 of them will be a glazed Macaron. Pierre wants to make all his clients happy but also he want to make the least possible trays of glazed Macarons he can. Knowing the Pierre’s clients preferences can you tell which Macarons flavours will be glazed or if it is not possible to make all the clients happy? Input The first line of the input contains an integer tc, the number of test cases. Each test case begins with a line containing two integers n and m (1 ≤ n, m ≤ 2000) the number of Macaron’s flavours and the number of clients. The next line contains n strings s1, s2, s3, ..., sn, the name of each Macaron flavour that Pierre will prepare(s whitout blank spaces). Following that, there are m lines, one for each client preferences. Following that, there are m lines, one for each client’s list of preferences. Each client’s list of preferences begins with a number a (1 ≤ a ≤ n) the amount of preferences he has. Next there are a preferences separated by a blank space, each preference is formed by one integer t and one string f separated by a blank space, denoting the type and the flavour of the Macaron. The type of each preference can only be 1 if it is glazed or 2 if it is traditional. It is guaranteed that the lenght of each string does not exceed 100 characters and that the flavour of the preference will be prepared by Pierre. Output For each test case if it is possible that Pierre makes all his clients happy print one line with the amount of glased trays that Pierre has to do, followed for the list of the glased flavours in alphabtical order, one per line. If it’s not possible, print ‘Impossible’ instead. Explanation: In the second test case, it is impossible to make all his clients happy because client 2 wants a glazed Macaron au-caramel and client 3 wants a traditional Macaron au-caramel and Pierre only do 1 tray of every flavour. Sample Input 3

2/2 54 grains-de-poivre au-citron au-chocolat a-la-myrtille a-la-vanille 1 1 au-citron 3 2 a-la-vanille 2 au-chocolat 1 a-la-myrtille 3 1 a-la-vanille 2 a-la-myrtille 2 au-chocolat 2 2 au-citron 1 grains-de-poivre 33 au-chocolat au-caramel au-miel 2 2 au-miel 2 au-caramel 1 1 au-caramel 1 2 au-caramel 53 au-chocolat au-caramel au-miel a-la-vanille a-la-rose 2 2 au-caramel 2 au-miel 3 2 au-miel 2 a-la-vanille 2 a-la-rose 2 2 au-chocolat 2 au-caramel Sample Output 2 au-citron grains-de-poivre Impossible 0