I am trying **Subtask 1** of this problem Department Strengths | CodeChef.

This is my code

```
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long
#define out(x) cout<<x<<"\n"
#define vout(x,n) f(i,1,n+1)cout<<x[i]<<" "
#define rep(i,n) for(int i(0); i<n; i++)
#define f(i,a,b) for(int i(a); i<b; i++)
#define vi vector<int>
#define pb push_back
const int MAXN = 1e5+10;
vector<vi> adj(MAXN);
vi depth(MAXN, -1);
void dfs(int u){
for(int v : adj[u]){
if(depth[v] == -1){
depth[v] = depth[u] + 1;
dfs(v);
}
}
}
int32_t main(){
int t; cin>>t;
while(t--){
rep(i,MAXN){depth[i] = -1; adj[i].clear();}
int n, m, x, y; cin>>n>>m;
rep(i,m){
cin>>x>>y;
adj[x].pb(y);
adj[y].pb(x);
}
int head;
if(n&1)head = n;
else head = 1;
depth[head] = 1;
dfs(head);
//vout(depth,n);
int ans=0; f(i,1,n+1)ans += depth[i];
if(n&1)cout<<"0 "<<ans<<"\n";
else cout<<ans<<" 0\n";
}
return 0;
}
```

It seems my approach is correct but there is some issue with the implementation.

Can someone tell me when the code fails? Solution: 58574643 | CodeChef