XORORED July cookoff 2021.code is exactly same to the video editorial still WA

It gives AC if i change x&arr[i] to x|arr[i].But shouldn’t it Give AC for Both?

 #include"bits/stdc++.h"
#define ll long long int
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector<ll> arr(n);
      

        for(ll i=0;i<n;i++)
         cin>>arr[i];

         ll x=-1;

         for(ll i=0;i<n;i++)
          x=x&arr[i];        

        ll ans=0;
         for(ll i=0;i<n;i++)
         {
           ans=ans|(arr[i]^x);
         }    

         cout<<x<<" "<<ans<<endl;

    }

    return 0;
}