Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i=0; i<(int64_t)(n); i++)
#define all(v) v.begin(), v.end()
//d

int N, M;
vector< vector< int > > data(100000,vector<int> (0));
vector< bool > check(100000);
vector< int > ans(100000);
queue< int > q1, q2;

void dfs(int i, int j){
  
  if(check[i-1]) return;
  else check[i-1] = true;
  ans[i-1]=j;
  for(int x: data[i-1]){
    q1.push(x);
    q2.push(i);
  }
  return;
  
}

void search(){
  
  q1.push(1);
  q2.push(-1);
  while(q1.size()!=0){
    dfs(q1.front(), q2.front());
    q1.pop();
    q2.pop();
  }
  return;
  
}

int main(){
  
  cout << "Yes" << endl;
  cin >> N >> M;
  rep(i, M){
    int a, b; cin >> a >> b;
    data[a-1].push_back(b);
    data[b-1].push_back(a);
  }
  
  search();
  
  rep(i, N) if(i!=0) cout << ans[i] << endl;
  
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:18:14: error: reference to 'data' is ambiguous
   18 |   for(int x: data[i-1]){
      |              ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:8:25: note:                 'std::vector<std::vector<int> > data'
    8 | vector< vector< int > > data(100000,vector<int> (0));
      |                         ^~~~
a.cc: In function 'int main()':
a.cc:45:5: error: reference to 'data' is ambiguous
   45 |     data[a-1].push_back(b);
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:8:25: note:                 'std::vector<std::vector<int> > data'
    8 | vector< vector< int > > data(100000,vector<int> (0));
      |                         ^~~~
a.cc:46:5: error: reference to 'data' is ambiguous
   46 |     data[b-1].push_back(a);
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:8:25: note:                 'std::vector<std::vector<int> > data'
    8 | vector< vector< int > > data(100000,vector<int> (0));
      |                         ^~~~