1. Java, Peter Schnitzler

/*Problem : 193
*Author : Peter Schnitzler
*Status : WA?
*Runtime : 0.29
*/

import java.util.Scanner;

public class Main
{

public static void main(String[] args) throws Exception
{
Scanner scan = new Scanner(System.in);

//how many graphs there are
final int rounds = scan.nextInt();

for (int roundCount = 0; roundCount < rounds; roundCount++)
{

final int nodes = scan.nextInt(); //number of nodes
boolean connections [][] = new boolean[nodes][nodes]; //matrix of the edges
int connectionCount[] = new int[nodes]; //number of uncolored connections of a node
int blackNode [] = new int[nodes]; //color of nodes
int countOfBlackNodes = 0;

readEdges(connectionCount, connections, scan);

int nodesNotColored = nodes;



while (nodesNotColored > 0)
{
int min = Integer.MAX_VALUE; //lowest connection count found
int minPos = -1; //position of that count


for (int count = 0; count < nodes; count++)
{
//the node is not colored
if (blackNode[count] == 0)
{
//the node is smaler that the smalest so far
if (connectionCount[count] < min)
{
minPos = count;
min = connectionCount[count];
}
}
}

//color the found node black
nodesNotColored--;
blackNode[minPos] = 1;
countOfBlackNodes++;


//color the connected nodes white
for (int count = 0; count < nodes; count++)
{
if (connections[minPos][count])
{
if (blackNode[count] == 0)
{
blackNode[count] = -1;
nodesNotColored--;


for (int underCount = 0; underCount < nodes; underCount++)
{
if (connections[count][underCount])
{
if (blackNode[underCount] == 0)
{
connectionCount[underCount]--;
}
}
}
}
}
}
}


StringBuilder output = new StringBuilder(countOfBlackNodes + "\n");

for (int count = 0; count < blackNode.length; count++)
{
if (blackNode[count] == 1)
{
output.append((count + 1) + " ");
}
}

System.out.println(output.toString().trim());
}
}


private static void readEdges(int connectionCount[], boolean connections[][], Scanner scan)
{
final int edges = scan.nextInt(); //number of edges

for (int edgeCount = 0; edgeCount < edges; edgeCount++)
{
//read a edge
final int n1 = scan.nextInt() - 1;
final int n2 = scan.nextInt() - 1;

//inc the number of connections for the nodes
connectionCount[n1]++;
connectionCount[n2]++;

//write a edge in the edge maxtrix
connections[n1][n2] = true;
connections[n2][n1] = true;
}
}
}