/******************************************************* * Copyright (C) 2015 Haotian Wu * * This file is the solution to the question: * https://www.hackerrank.com/challenges/bfsshortreach * * Redistribution and use in source and binary forms are permitted. *******************************************************/ #include #include #include #include #include #include #include #include #include #include using namespace std; // We don't care the '6' distance. We just treat this as a unweighted graph, and we multiply 6 when output. // Simple BFS. int main() { int tt; scanf("%d",&tt); while (tt--) { int n,m; scanf("%d %d",&n,&m); vector adj[1001]; for (int i=0;i