BFS-Shortest Path

#include<bits/stdc++.h>
using namespace std;
bool visited[100001];
void BFS(int s,int A[],vector V[])
{

list q;

q.push_back(s);
visited[s]=true;
while(!q.empty())
{
int j=q.front();
q.pop_front();
for(auto i=V[j].begin();i!=V[j].end();i++)
{
if(visited[*i]==false)
{
q.push_back(*i);
visited[*i]=true;
A[*i]=A[s]+1;
}
}
}

}
int main() {
int i,n,a,b,s,m,t;

cin>>t;
while(t--)
{
    vector<int> V[100001];
    int A[100001]={0};
cin>>n>>m;
for(i=1;i<=n;i++)
visited[i]=false;
for(i=0;i<m;i++)
{
    cin>>a>>b;
    V[a].push_back(b);
    V[b].push_back(a);
    }

cin>>s;
A[s]=0;
BFS(s,A,V);
for(i=1;i<=n;i++)
{

if(i!=s)
{
    if(A[i]==0)
    cout<<-1<<" ";
    else
    cout<<A[i]*6<<" ";

}

}
cout<<endl;
}
return 0;
}
I am not able to find error in this.