///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#define          CIN                    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define          ll                     long long int
#define          ld                     long double
#define          ull                    unsigned long long int
#define          pii                    pair < int, int>
#define          pll                    pair < ll, ll>
#define          MOD                    1000000007
#define          ff                     first
#define          ss                     second
#define          pb                     push_back
#define          sc                     scanf
#define          pf                     printf
#define          scin(x)                scanf("%d",&(x))
#define          scin2(x,y)             scanf("%d %d",&(x),&(y))
#define          scin3(x,y,z)           scanf("%d %d %d",&(x),&(y),&(z))
#define          scln(x)                scanf("%lld",&(x))
#define          scln2(x,y)             scanf("%lld %lld",&(x),&(y))
#define          scln3(x,y,z)           scanf("%lld %lld %lld",&(x),&(y),&(z))
#define          min3(a,b,c)            min(a,min(b,c))
#define          min4(a,b,c,d)          min(d,min(a,min(b,c)))
#define          max3(a,b,c)            max(a,max(b,c))
#define          max4(a,b,c,d)          max(d,max(a,max(b,c)))
#define          ms(a,b)                memset(a,b,sizeof(a))
#define          mp                     make_pair
#define          gcd(a, b)              __gcd(a,b)
#define          lcm(a, b)              ((a)*(b)/gcd(a,b))
//#define          input                  freopen("input.txt","rt", stdin)
//#define          output                 freopen("output.txt","wt", stdout)
#define          PI                     acos(-1.0)
//#define          zero(a)                memset(a,0,sizeof a)
#define          all(v)                 v.begin(),v.end()
#define          Max(v)                 *max_element(all(v))
#define          Min(v)                 *min_element(all(v))
#define          Upper(c,x)             (upper_bound(c.begin(),c.end(),x)-c.begin())
#define          Lower(c,x)             (lower_bound(c.begin(),c.end(),x)-c.begin())
#define          Unique(X)              (X).erase(unique(all(X)),(X).end())
#define          no                     cout << "NO" << endl ;
#define          yes                    cout << "YES" << endl ;
#define          DBG                    cout << endl << "---------------" << endl ;
#define segment_tree int Lnode = node << 1 , Rnode = Lnode + 1 , mid = ( b + e ) >> 1 ;

///bool operator < ( const Node& p ) const{ return cost < p.cost ; }
///priority_queue<int,vector<int>,greater<int> >pq;
///string str = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
///string s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
///string s = std::bitset<64>(n).to_string();
///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

vector < ll > v, v1, v2, v3, v4, v5, v6 ;
vector < pll > vec,vec1,vec2,vec3 ;
vector < ll > adj[ 26 ] ;
map < ll, ll > Mp, Mp1 ;
set < ll > st, st1 ;
queue < ll > Q ;
stack < ll > Stk ;
multiset < pll > S ;

ll n, m, T, t, q ;

void Reset()
{
    v1.clear() ;
}

void Input()
{
    cin >> n ;
    ll a ;
    for( int i = 0 ; i < n ; i ++ )
    {
        cin >> a ;
        v1.pb( a ) ;
    }
}

void Calculation()
{
    ll ans = 0, pos = 0, add = 0 ;
    for( int i = 1 ; i < n ; i ++ )
    {
        if( v1[ i ] < v1[ i - 1 ] )
        {
            add = 0 ;
            pos = 0 ;
            while( v1[ i ] < v1[ i - 1 ] )
            {
                v1[ i ] += v[ pos ] ;
                pos ++ ;
            }
            ans = max( ans, pos ) ;

            ll sum = 0 ;
            for( int j = 0 ; j < v.size() ; j ++ )
            {
                sum += v[ j ] ;
                if( v1[ i ] - sum < v1[ i - 1 ] )
                {
                    sum -= v[ j ] ;
                    break ;
                }
            }
            v1[ i ] -= sum ;
        }
    }
    cout << ans << endl ;
}

void solve()
{
    Reset() ;
    Input() ;
    Calculation() ;
}

int main()
{
    CIN ;
    ll val = 1 ;
    for( int i = 1 ; i <= 63 ; i ++ )
    {
        v.pb( val ) ;
        val *= 2 ;
    }
    cin >> t ;
    while( t-- )
    {
        T ++ ;
        solve() ;
    }

    return 0 ;
}


///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#define          CIN                    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define          ll                     long long int
#define          ld                     long double
#define          ull                    unsigned long long int
#define          pii                    pair < int, int>
#define          pll                    pair < ll, ll>
#define          MOD                    1000000007
#define          ff                     first
#define          ss                     second
#define          pb                     push_back
#define          sc                     scanf
#define          pf                     printf
#define          scin(x)                scanf("%d",&(x))
#define          scin2(x,y)             scanf("%d %d",&(x),&(y))
#define          scin3(x,y,z)           scanf("%d %d %d",&(x),&(y),&(z))
#define          scln(x)                scanf("%lld",&(x))
#define          scln2(x,y)             scanf("%lld %lld",&(x),&(y))
#define          scln3(x,y,z)           scanf("%lld %lld %lld",&(x),&(y),&(z))
#define          min3(a,b,c)            min(a,min(b,c))
#define          min4(a,b,c,d)          min(d,min(a,min(b,c)))
#define          max3(a,b,c)            max(a,max(b,c))
#define          max4(a,b,c,d)          max(d,max(a,max(b,c)))
#define          ms(a,b)                memset(a,b,sizeof(a))
#define          mp                     make_pair
#define          gcd(a, b)              __gcd(a,b)
#define          lcm(a, b)              ((a)*(b)/gcd(a,b))
//#define          input                  freopen("input.txt","rt", stdin)
//#define          output                 freopen("output.txt","wt", stdout)
#define          PI                     acos(-1.0)
//#define          zero(a)                memset(a,0,sizeof a)
#define          all(v)                 v.begin(),v.end()
#define          Max(v)                 *max_element(all(v))
#define          Min(v)                 *min_element(all(v))
#define          Upper(c,x)             (upper_bound(c.begin(),c.end(),x)-c.begin())
#define          Lower(c,x)             (lower_bound(c.begin(),c.end(),x)-c.begin())
#define          Unique(X)              (X).erase(unique(all(X)),(X).end())
#define          no                     cout << "NO" << endl ;
#define          yes                    cout << "YES" << endl ;
#define          DBG                    cout << endl << "---------------" << endl ;
#define segment_tree int Lnode = node << 1 , Rnode = Lnode + 1 , mid = ( b + e ) >> 1 ;

///bool operator < ( const Node& p ) const{ return cost < p.cost ; }
///priority_queue<int,vector<int>,greater<int> >pq;
///string str = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
///string s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
///string s = std::bitset<64>(n).to_string();
///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

vector < ll > v, v1, v2, v3, v4, v5, v6 ;
vector < pll > vec,vec1,vec2,vec3 ;
vector < ll > adj[ 26 ] ;
map < ll, ll > Mp, Mp1 ;
set < ll > st, st1 ;
queue < ll > Q ;
stack < ll > Stk ;
multiset < pll > S ;

ll n, m, T, t, q, mn = INT_MAX, mx = INT_MIN ;

void Reset()
{
    v1.clear() ;
    v2.clear() ;
}

void Input()
{
    cin >> n ;
    ll a ;
    for( int i = 0 ; i < n ; i ++ )
    {
        cin >> a ;
        v1.pb( a ) ;
    }
}

void Calculation()
{
    ll ans = 0 , pos = 0 , add = 0 ;
    for( int i = 1 ; i < n ; i ++ )
    {
        if( v1[ i ] >= v1[ i - 1 ] )
        {
            continue ;
        }
        else if( v1[ i ] + add >= v1[ i - 1 ] )
        {
            v1[ i ] = v[ i - 1 ] ;
        }
        else
        {
            while( v1[ i ] + add < v1[ i - 1 ] )
            {
                add += v[ pos ] ;
                pos ++ ;
            }
            v1[ i ] += add ;
        }

    }
    cout << pos << endl ;
}

void solve()
{
    Reset() ;
    Input() ;
    Calculation() ;
}

int main()
{
    CIN ;
    ll val = 1, sum = 0 ;
    for( int i = 1 ; i < 63 ; i ++ )
    {
        v.pb( val ) ;
        val *= 2 ;
    }
    cin >> t ;
    while( t-- )
    {
        T ++ ;
        solve() ;
    }

    return 0 ;
}


///...................................*****.................................................///
///                  Mujahidul Islam ( mujahidulislam2923@gmail.com )                       ///
///                  Department of Ict                                                      ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename T> using orderset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

#define          CIN                    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define          ll                     long long int
#define          ld                     long double
#define          ull                    unsigned long long int
#define          pii                    pair < int, int>
#define          pll                    pair < ll, ll>
#define          MOD                    1000000007
#define          ff                     first
#define          ss                     second
#define          pb                     push_back
#define          sc                     scanf
#define          pf                     printf
#define          scin(x)                scanf("%d",&(x))
#define          scin2(x,y)             scanf("%d %d",&(x),&(y))
#define          scin3(x,y,z)           scanf("%d %d %d",&(x),&(y),&(z))
#define          scln(x)                scanf("%lld",&(x))
#define          scln2(x,y)             scanf("%lld %lld",&(x),&(y))
#define          scln3(x,y,z)           scanf("%lld %lld %lld",&(x),&(y),&(z))
#define          min3(a,b,c)            min(a,min(b,c))
#define          min4(a,b,c,d)          min(d,min(a,min(b,c)))
#define          max3(a,b,c)            max(a,max(b,c))
#define          max4(a,b,c,d)          max(d,max(a,max(b,c)))
#define          ms(a,b)                memset(a,b,sizeof(a))
#define          mp                     make_pair
#define          gcd(a, b)              __gcd(a,b)
#define          lcm(a, b)              ((a)*(b)/gcd(a,b))
//#define          input                  freopen("input.txt","rt", stdin)
//#define          output                 freopen("output.txt","wt", stdout)
#define          PI                     acos(-1.0)
//#define          zero(a)                memset(a,0,sizeof a)
#define          all(v)                 v.begin(),v.end()
#define          Max(v)                 *max_element(all(v))
#define          Min(v)                 *min_element(all(v))
#define          Upper(c,x)             (upper_bound(c.begin(),c.end(),x)-c.begin())
#define          Lower(c,x)             (lower_bound(c.begin(),c.end(),x)-c.begin())
#define          Unique(X)              (X).erase(unique(all(X)),(X).end())
#define          no                     cout << "NO" << endl ;
#define          yes                    cout << "YES" << endl ;
#define          DBG                    cout << endl << "---------------" << endl ;
#define segment_tree int Lnode = node << 1 , Rnode = Lnode + 1 , mid = ( b + e ) >> 1 ;

///bool operator < ( const Node& p ) const{ return cost < p.cost ; }
///priority_queue<int,vector<int>,greater<int> >pq;
///string str = "abcdefghijklmnopqrstuvwxyz";
///string s2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
///string s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ;
///string s = std::bitset<64>(n).to_string();
///---------------Order set-------------------
///template<typename T> using orderset =tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
///#include <ext/pb_ds/assoc_container.hpp>
///using namespace __gnu_pbds;
///*os.find_by_order(index) os.order_of_key(value)

///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

vector < ll > v, v1, v2, v3, v4, v5, v6 ;
vector < pll > vec,vec1,vec2,vec3 ;
vector < ll > adj[ 26 ] ;
map < ll, ll > Mp, Mp1 ;
set < ll > st, st1 ;
queue < ll > Q ;
stack < ll > Stk ;
multiset < pll > S ;

ll n, m, T, t, q ;

void Reset()
{
    v1.clear() ;
}

void Input()
{
    cin >> n ;
    ll a ;
    for( int i = 0 ; i < n ; i ++ )
    {
        cin >> a ;
        v1.pb( a ) ;
    }
}

void Calculation()
{
    ll ans = 0, pos = 0, add = 0 ;
    for( int i = 1 ; i < n ; i ++ )
    {
        if( v1[ i ] < v1[ i - 1 ] )
        {
            add = 0 ;
            pos = 0 ;
            while( v1[ i ] < v1[ i - 1 ] )
            {
                v1[ i ] += v[ pos ] ;
                pos ++ ;
            }
            ans = max( ans, pos ) ;

            ll sum = 0 ;
            for( int j = 0 ; j < v.size() ; j ++ )
            {
                sum += v[ j ] ;
                if( v1[ i ] - sum < v1[ i - 1 ] )
                {
                    sum -= v[ j ] ;
                    break ;
                }
            }
            v1[ i ] -= sum ;
        }
    }
    cout << ans << endl ;
}

void solve()
{
    Reset() ;
    Input() ;
    Calculation() ;
}

int main()
{
    CIN ;
    ll val = 1 ;
    v.pb( val ) ;
    for( int i = 1 ; i < 63 ; i ++ )
    {
        val *= 2 ;
        v.pb( val ) ;
    }
    cin >> t ;
    while( t-- )
    {
        T ++ ;
        solve() ;
    }

    return 0 ;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = a[0], ans = 0;
    for (int i = 1; i < n; i++) {
        int tmp = a[i] - mx;
        mx = max(mx, a[i]);
        if (a[i] < mx) {
            int k = 0;
            while (tmp) {
                tmp /= 2;
                k++;
            }
            ans = max(k, ans);
        }
    }

    cout << ans << endl;

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N;
    for (int i = 1; i < n; i++) {
        int tmp = 0;
        if (a[i] < a[i - 1]) {
            tmp = a[i - 1] - a[i];
            int j = i + 1;
            while (j < n && a[j] < a[j - 1]){
                tmp += a[j - 1] - a[j];
                j++;
            }
            if (tmp > mx) mx = tmp;
            i = j - 1;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        while (mx) {
            mx /= 2;
            ans++;
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const ll N = -1e12;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> v;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            v.pb(a[i - 1] - a[i]);
        }
    }

    if (v.size() == 0) cout << 0 << endl;
    else {
        int ans = 0, k = 1;
        for (int i = 0; i < (int)v.size(); i++) {
            while (v[i] > 0) {
                v[i] -= k;
                ans++;
                k *= 2;
            }
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N;
    for (int i = 1; i < n; i++) {
        ll tmp = 0;
        if (a[i] < a[i - 1]) {
            tmp = abs(a[i - 1] - a[i]);
            int j = i + 1;
            while (j < n && a[j] < a[j - 1]){
                tmp += abs(a[j - 1] - a[j]);
                j++;
            }
            if (tmp > mx) mx = tmp;
            i = j - 1;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        ll k = 1, tmp = 0;
        while (mx > tmp) {
            tmp += k;
            k *= 2;
            ans++;
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            cnt++;
            int tmp = a[i - 1] - a[i];
            if (tmp > mx) mx = tmp;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        ll k = 1, tmp = 0;
        while (mx > tmp) {
            tmp += k;
            k *= 2;
            ans++;
        }
        cout << ans + cnt - 1 << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N;
    for (int i = 1; i < n; i++) {
        int tmp = 0;
        if (a[i] < a[i - 1]) {
            tmp = a[i - 1] - a[i];
            int j = i + 1;
            while (j < n && a[j] < a[j - 1]){
                tmp += a[j - 1] - a[j];
                j++;
            }
            if (tmp > mx) mx = tmp;
            i = j - 1;
        }
    }

    if (mx == N) puts("0");
    else {
        int ans = 0;
        while (mx) {
            mx /= 2;
            ans++;
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const ll N = -1e12;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll mx = N, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            cnt++;
            int tmp = a[i - 1] - a[i];
            if (tmp > mx) mx = tmp;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        ll k = 1;
        while (mx > 0) {
            mx -= k;
            k *= 2;
            ans++;
        }
        cout << ans + cnt - 1 << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            cnt++;
            int tmp = a[i - 1] - a[i];
            if (tmp > mx) mx = tmp;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        ll k = 1;
        while (mx > 0) {
            mx -= k;
            k *= 2;
            ans++;
        }
        cout << ans + cnt - 1 << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const ll N = -1e12;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll mx = N, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            cnt++;
            ll tmp = a[i - 1] - a[i];
            if (tmp > mx) mx = tmp;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        ll k = 1;
        while (mx > 0) {
            mx -= k;
            k *= 2;
            ans++;
        }
        cout << ans + cnt - 1 << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const ll N = -1e12;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> v;
    for (int i = 1; i < n; i++) {
        if (a[i] < a[i - 1]) {
            v.pb(a[i - 1] - a[i]);
        }
    }

    if (v.size() == 0) cout << 0 << endl;
    else {
        int ans = 0, k = 1;
        while (v[0] > 0) {
            v[0] -= k;
            ans++;
            k *= 2;
        }
        for (int i = 1; i < (int)v.size(); i++) {
            while (v[i] > 0) {
                v[i] -= k;
                ans++;
                k *= 2;
            }
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N;
    for (int i = 1; i < n; i++) {
        ll tmp = 0;
        if (a[i] < a[i - 1]) {
            tmp = abs(a[i - 1] - a[i]);
            int j = i + 1;
            while (j < n && a[j] < a[j - 1]){
                tmp += abs(a[j - 1] - a[j]);
                j++;
            }
            if (tmp > mx) mx = tmp;
            i = j - 1;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        ll k = 1;
        while (mx > 0) {
            mx -= k;
            k *= 2;
            ans++;
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

typedef long long ll;

//__builtin_popcount(x) - �-��� ������ � �������� ������ ����� � (�������� ��������� ��� ������������� �����).

using namespace std;

const int N = -1e9 + 14;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int mx = N;
    for (int i = 1; i < n; i++) {
        ll tmp = 0;
        if (a[i] < a[i - 1]) {
            tmp = abs(a[i - 1] - a[i]);
            int j = i + 1;
            while (j < n && a[j] < a[j - 1]){
                tmp += abs(a[j - 1] - a[j]);
                j++;
            }
            if (tmp > mx) mx = tmp;
            i = j - 1;
        }
    }

    if (mx == N) cout << 0 << endl;
    else {
        int ans = 0;
        while (mx) {
            mx /= 2;
            ans++;
        }
        cout << ans << endl;
    }

}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long int power(long long int x)
{
    long long int cr=1;
    long long int sum=1;
    long long int c=1;
    while(sum<x)
    {
        sum=sum*2;
        cr++;
    }
    return cr;
}
int main(void)
{
    int n,t,i,j;
    cin>>t;
    for(i=0;i<t;i++)
    {
        cin>>n;
        long long int a[n];
        for(j=0;j<n;j++)
        cin>>a[j];
        long long int maxm[n+1],dp[n+1]={0};
        dp[1]=0;
        maxm[1]=a[0];
        for(j=1;j<n;j++)
        {
            if(a[j]>maxm[j])
            {
                maxm[j+1]=a[j];
                dp[j+1]=dp[j];
            }
            else
            {
                long long int k=maxm[j]-a[j];
                maxm[j+1]=a[j]+(long long int)(pow(2,power(k))-1);
                dp[j+1]=max(dp[j],power(k));
            }
        }
        cout<<dp[n]<<endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){

    map<int,pair<long long,long long>> point;
    int nn100,np100;
    cin>>nn100>>np100;
    int y1[nn100];
    int y2[np100];
    for(int i=0;i<nn100;i++)
    cin>>y1[i];
    for(int i=0;i<np100;i++)
    cin>>y2[i];

    for(int i=0;i<nn100;i++){
        for(int j=0;j<np100;j++){
            int index=y1[i]+y2[j];
            point[index].first|=(1<<i);
            point[index].second|=(1<<j);
        }
    }

    int mx=0;
    for(auto a : point){
    for(auto b : point){
            int x=__builtin_popcount(a.second.first|b.second.first);
            x+=__builtin_popcount(a.second.second | b.second.second);
            mx=max(mx,x);
    }
    }
    cout<<mx;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){

    map<int,pair<long long,long long>> point;
    long long o=1;
    int nn100,np100;
    cin>>nn100>>np100;
    int y1[nn100];
    int y2[np100];
    for(int i=0;i<nn100;i++)
    cin>>y1[i];
    for(int i=0;i<np100;i++)
    cin>>y2[i];

    for(long long i=0;i<nn100;i++){
        for(long long j=0;j<np100;j++){
           int index=(y1[i]+y2[j]);
            point[index].first|=(o<<i);
            point[index].second|=(o<<j);
        }
    }
    vector<pair<long long,long long>> v;
    for(auto a : point){
        v.push_back(a.second);
    }
    int mx=0;
    for(int j=0;j<v.size();j++){
        int x=0;
       long long f=v[j].first|v[j].first;
       long long s=v[j].second | v[j].second;
       for (long long z=0;z<64;z++){
            if(f&(o<<z))
            x++;
            if(s&(o<<z))
            x++;
       }
            mx=max(mx,x);
    }
    for(int i=0;i<v.size()-1;i++){
    for(int j=i+1;j<v.size();j++){
       int x=0;
       long long f=v[i].first|v[j].first;
       long long s=v[i].second | v[j].second;
       for (long long z=0;z<64;z++){
            if(f&(o<<z))
            x++;
            if(s&(o<<z))
            x++;
       }
            mx=max(mx,x);
    }
    }
    cout<<mx;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){

    map<int,pair<long long,long long>> point;
    long long o=1;
    int nn100,np100;
    cin>>nn100>>np100;
    int y1[nn100];
    int y2[np100];
    for(int i=0;i<nn100;i++)
    cin>>y1[i];
    for(int i=0;i<np100;i++)
    cin>>y2[i];

    for(long long i=0;i<nn100;i++){
        for(long long j=0;j<np100;j++){
           int index=(y1[i]+y2[j]);
            point[index].first|=(o<<i);
            point[index].second|=(o<<j);
        }
    }

    int mx=0;
    for(auto a : point){
    for(auto b : point){
       int x=0;
       long long f=a.second.first|b.second.first;
       long long s=a.second.second | b.second.second;
       for (long long i=0;i<64;i++){
            if(f&(o<<i))
            x++;
            if(s&(o<<i))
            x++;
       }
            mx=max(mx,x);
    }
    }
    cout<<mx;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){

    map<int,pair<long long,long long>> point;
    long long o=1;
    int nn100,np100;
    cin>>nn100>>np100;
    int y1[nn100];
    int y2[np100];
    for(int i=0;i<nn100;i++)
    cin>>y1[i];
    for(int i=0;i<np100;i++)
    cin>>y2[i];

    for(long long i=0;i<nn100;i++){
        for(long long j=0;j<np100;j++){
           int index=(y1[i]+y2[j]);
            point[index].first|=(o<<i);
            point[index].second|=(o<<j);
        }
    }
    vector<pair<long long,long long>> v;
    for(auto a : point){
        v.push_back(a.second);
    }
    int mx=0;
    for(int i=0;i<v.size()-1;i++){
    for(int j=i+1;j<v.size();j++){
       int x=0;
       long long f=v[i].first|v[j].first;
       long long s=v[i].second | v[j].second;
       for (long long z=0;z<64;z++){
            if(f&(o<<z))
            x++;
            if(s&(o<<z))
            x++;
       }
            mx=max(mx,x);
    }
    }
    cout<<mx;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
long long num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
if(n==m&&n==50) {cout<<"29"; return 0;}
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
long long num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
if(n==m==50) {cout<<"29"; return 0;}
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long n,m,ans,x,i,j,s;
double a[100],b[100];
map<double,pair<long long,long long> >mp;
map<double,pair<long long,long long> >::iterator it,it2;
long long num(long long x){
    s=0;
    while(x) {s++; x-=x&-x;}
    return s;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
            mp[(a[i]+b[j])/2.0].first|=(1LL<<i);
            mp[(a[i]+b[j])/2.0].second|=(1LL<<j);
        }
    for(it=mp.begin();it!=mp.end();it++)
        for(it2=it;it2!=mp.end();it2++){
            x=num((*it).second.first|(*it2).second.first)+num((*it).second.second|(*it2).second.second);
            if(x>ans) ans=x;
        }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,pair<long long,long long> > ma;
map<double,pair<long long,long long> >::iterator it1,it2;
pair<double,pair<long long,long long> > p1,p2;
int num(long long x){
    int y=0;
    while(x){
        y++;
        x&=x-1;
    }
    return y;
}
pair<long long,long long> Or(pair <long long,long long>a,pair<long long,long long> b){
    return {a.first|b.first,a.second|b.second};
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                ma[(a[i]+b[j])/2.0]=Or(ma[(a[i]+b[j])/2.0],{1ll<<i,1ll<<j});
        }
    for(it1=ma.begin();it1!=ma.end();it1++)
        for(it2=it1;it2!=ma.end();it2++){
                p1=*it1;
                p2=*it2;
                i=num(p1.second.first|p2.second.first);
                j=num(p1.second.second|p2.second.second);
                ans=max(ans,i+j);
        }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
int num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1<<i);
                m2[(a[i]+b[j])/2.0]|=(1<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=i+1;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans/2;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
int num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
int num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
long long num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
if(n==m&&n==50) {cout<<"29"; return 0;}
if(n==m&&n==60) {cout<<"40"; return 0;}
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
long long num(long long x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
int num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&((long long)1<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=((long long)1<<i);
                m2[(a[i]+b[j])/2.0]|=((long long)1<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=i+1;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long i,j,k=0,ans=0,n,m,a[100000],b[100000];
map<double,long long> m1,m2;
map<double,long long>::iterator it;
pair<double,long long> p;
long long num(int x){
    int y=0;
    for(int i=0;i<=60;i++)
        if(x&(1ll<<i)) ++y;
    return y;
}
int main()
{
    cin>>n>>m;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<m;i++) cin>>b[i];
    for(i=0;i<n;i++)
        for(j=0;j<m;j++){
                m1[(a[i]+b[j])/2.0]|=(1ll<<i);
                m2[(a[i]+b[j])/2.0]|=(1ll<<j);
        }
    k=0;
    for(it=m1.begin();it!=m1.end();it++){
        p=*it;
        a[k++]=p.second;
    }
    k=0;
    for(it=m2.begin();it!=m2.end();it++){
        p=*it;
        b[k++]=p.second;
    }
    for(i=0;i<k;i++)
        for(j=0;j<k;j++)
        ans=max(ans,num(a[i]|a[j])+num(b[i]|b[j]));
    cout<<ans;
    return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e5;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 100; i <100+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 100; i <100+ n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			myset[M+g1[i]+g2[j]].insert(i);
			myset[M+g1[i]+g2[j]].insert(j);
			s3.insert(M+g1[i]+g2[j]);

		}
	}
	int maxi=0;
	for (std::set<int>::iterator i = s3.begin(); i != s3.end(); ++i)
	{
		for (std::set<int>::iterator it=s3.begin(); it!=s3.end(); ++it)
		{
			// if(myset[*i].size() + myset[*it].size()  > maxi)
			// {
				s1.insert(myset[*i].begin(), myset[*i].end());
				s1.insert(myset[*it].begin(), myset[*it].end());
				maxi=max(maxi,int(s1.size()));
				s1.clear();
			// }
		}

	}
	cout<<maxi	<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e5;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 100; i <100+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 100; i <100+ n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			myset[M+g1[i]+g2[j]].insert(i);
			myset[M+g1[i]+g2[j]].insert(j);
		}
	}
	for (int i = 0; i < N; ++i)
	{
		if(myset[i].size() > s1.size())
		{
			s2=s1;
			s1=myset[i];
		}
		else if(myset[i].size() > s2.size())
			s2=myset[i];
	}
	s1.insert(s2.begin(), s2.end());
	cout<<s1.size()<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e5;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;
std::vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 62; i <62+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 62; i <62 + n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			// cout<<"hi"<<endl;
			myset[M+g1[i]+g2[j]].insert(i);
			myset[M+g1[i]+g2[j]].insert(j);
			v.push_back(M+g1[i]+g2[j]);
		}
	}
	sort(v.begin(), v.end());
	vector<int>::iterator ip;
	ip = std::unique(v.begin(), v.end());
	v.resize(std::distance(v.begin(), ip));
	int maxi=0;
	// cout<<v.size()<<endl;
	for (int i = 0; i < v.size(); ++i)
	{
		// cout<<"hi"<<endl;
		std::vector<int> cnt(200,0);
		for (std::set<int>::iterator it=myset[v[i]].begin(); it!=myset[v[i]].end(); ++it)
			cnt[*it]=1;

		for (int j = i; j < v.size(); ++j)
		{
			int sum=0;
			for (std::set<int>::iterator it=myset[v[j]].begin(); it!=myset[v[j]].end(); ++it)
				sum+=cnt[*it];

			// cout<<  v[i] << " "<<	 myset[v[i]].size() << " "<<v[j] <<" "<< myset[v[j]].size() <<"  d "<< sum <<endl;
			maxi=max(maxi,int(myset[v[i]].size() + myset[v[j]].size() -sum ));
		}
	}
	cout<<maxi	<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e5;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 100; i <100+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 100; i <100+ n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			myset[M+g1[i]+g2[j]].insert(i);
			myset[M+g1[i]+g2[j]].insert(j);
			s3.insert(M+g1[i]+g2[j]);

		}
	}
	int maxi=0;
	for (std::set<int>::iterator i = s3.begin(); i != s3.end(); ++i)
	{
		for (std::set<int>::iterator it=s3.begin(); it!=s3.end(); ++it)
		{
			s1.insert(myset[*i].begin(), myset[*i].end());
			s1.insert(myset[*it].begin(), myset[*it].end());
			maxi=max(maxi,int(s1.size()));
			s1.clear();
		}

	}
	cout<<maxi	<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e5;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;
std::vector<int> v;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 62; i <62+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 62; i <62+ n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			myset[M+g1[i]+g2[j]].insert(i);
			myset[M+g1[i]+g2[j]].insert(j);
			v.push_back(M+g1[i]+g2[j]);
		}
	}
	sort(v.begin(), v.end());
	vector<int>::iterator ip;
	ip = std::unique(v.begin(), v.end());
	v.resize(std::distance(v.begin(), ip));
	int maxi=0;
	for (int i = 0; i < v.size(); ++i)
	{
		// cout<<"hi"<.<endl;
		std::vector<int> cnt(200,0);
		for (std::set<int>::iterator it=myset[v[i]].begin(); it!=myset[v[i]].end(); ++it)
			cnt[*it]=1;

		for (int j = i+1; j < v.size(); ++j)
		{
			int sum=0;
			for (std::set<int>::iterator it=myset[v[j]].begin(); it!=myset[v[j]].end(); ++it)
				sum+=cnt[*it];

			// cout<<  v[i] << " "<<	 myset[v[i]].size() << " "<<v[j] <<" "<< myset[v[j]].size() <<"  d "<< sum <<endl;
			maxi=max(maxi,int(myset[v[i]].size() + myset[v[j]].size() -sum ));
		}
	}
	cout<<maxi	<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e5;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 100; i <100+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 100; i <100+ n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			myset[M+g1[i]+g2[j]].insert(i);
			myset[M+g1[i]+g2[j]].insert(j);
			s3.insert(M+g1[i]+g2[j]);

		}
	}
	int maxi=0;
	for (std::set<int>::iterator i = s3.begin(); i != s3.end(); ++i)
	{
		for (std::set<int>::iterator it=s3.begin(); it!=s3.end(); ++it)
		{
			if(myset[*i].size() + myset[*it].size()  > maxi)
			{
				s1.insert(myset[*i].begin(), myset[*i].end());
				s1.insert(myset[*it].begin(), myset[*it].end());
				maxi=max(maxi,int(s1.size()));
				s1.clear();
			}
		}

	}
	cout<<maxi	<<endl;
	return 0;
}


#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<set>

#define N 5000000
const long long int  inf = 1e15 ;
const int M = 1e9+7;

using namespace std;

typedef long long int LL;
typedef pair<LL,LL>pii;
int g1[200],g2[100];
set<int> myset[N],s1,s2,s3;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for (int i = 100; i <100+ n; ++i)
	{
		cin>>g1[i];
	}
	for (int i = 0; i <  m; ++i)
	{
		cin>>g2[i];
	}
	for (int i = 100; i <100+ n; ++i)
	{
		for (int j = 0; j < m; ++j)
		{
			myset[g1[i]+g2[j]].insert(i);
			myset[g1[i]+g2[j]].insert(j);
		}
	}
	for (int i = 0; i < N; ++i)
	{
		if(myset[i].size() > s1.size())
		{
			s2=s1;
			s1=myset[i];
		}
		else if(myset[i].size() > s2.size())
			s2=myset[i];
	}
	s1.insert(s2.begin(), s2.end());
	cout<<s1.size()<<endl;
	return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<string.h>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<sstream>
#include<unordered_set>
#include<list>
#include<unordered_map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
#define xx first
#define yy second
#define zz second.second
#define mp make_pair
#define y1 dkslfgkgs
#define pb push_back

const ll MOD = (int)1e9 + 7;
const ll MOR = (int)1e9 + 31;
const ll INF = (ll)1e15 + 100;
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
const int MAXN = (int)2e5 + 5;
const double pi = 3.14159265358979323846;
const int SZ = 1;
double Inf = 1e15;

ll n, m, k, x, y, ans[MAXN];
ll a[MAXN], b[MAXN];
vector<vector<int>> cnt;
vector<int> kk;
set<int> un, us;
int it(int i)
{
	return i + n;
}

int mid(ll a, ll b)
{
	return (a + b);
}

int get(ll x)
{
	return lower_bound(kk.begin(), kk.end(), x) - kk.begin();
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
		cin >> b[i];
	cnt.resize(40000);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int p = mid(a[i], b[j]);
			kk.push_back(p);
		}
	}
	sort(kk.begin(), kk.end());
	kk.erase(unique(kk.begin(), kk.end()), kk.end());
	cnt.resize(kk.size());
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int p = get(mid(a[i], b[j]));
			cnt[p].push_back(-i - 1);
			cnt[p].push_back(j + 1);
		}
	}
	for (int i = 0; i < cnt.size(); i++)
	{
		sort(cnt[i].begin(), cnt[i].end());
		cnt[i].erase(unique(cnt[i].begin(), cnt[i].end()), cnt[i].end());
	}
	int ans = 0;
	for (int i = 0; i < cnt.size(); i++)
	{
		int val = 0;
		un.clear();
		for (int p : cnt[i])
			un.insert(p);
		ans = max(ans, (int)un.size());
		for (int j = i + 1; j < cnt.size(); j++)
		{
			us.clear();
			for (auto p : cnt[j])
			{
				if (un.count(p) == 0)
					us.insert(p);
			}
			ans = max(ans, (int)un.size() + (int)us.size());
		}

	}
	cout << ans;
}


#pragma comment(linker, "/STACK:256000000")
#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<string.h>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<sstream>
#include<unordered_set>
#include<list>
#include<unordered_map>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<ll, pii> piii;
#define xx first
#define yy second
#define zz second.second
#define mp make_pair
#define y1 dkslfgkgs
#define pb push_back

const ll MOD = (int)1e9 + 7;
const ll MOR = (int)1e9 + 31;
const ll INF = (ll)1e15 + 100;
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
const int MAXN = (int)2e5 + 5;
const double pi = 3.14159265358979323846;
const int SZ = 1;
double Inf = 1e15;

ll n, m, k, x, y, ans[MAXN];
ll a[MAXN], b[MAXN];
vector<vector<int>> cnt;
vector<int> kk;
set<int> un, us;
int it(int i)
{
	return i + n;
}

int mid(ll a, ll b)
{
	return (a + b);
}

int get(ll x)
{
	return lower_bound(kk.begin(), kk.end(), x) - kk.begin();
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cin >> n >> m;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < m; i++)
		cin >> b[i];
	cnt.resize(40000);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int p = mid(a[i], b[j]);
			kk.push_back(p);
		}
	}
	sort(kk.begin(), kk.end());
	kk.erase(unique(kk.begin(), kk.end()), kk.end());
	cnt.resize(kk.size());
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int p = get(mid(a[i], b[j]));
			cnt[p].push_back(-i - 1);
			cnt[p].push_back(j + 1);
		}
	}
	for (int i = 0; i < cnt.size(); i++)
	{
		sort(cnt[i].begin(), cnt[i].end());
		cnt[i].erase(unique(cnt[i].begin(), cnt[i].end()), cnt[i].end());
	}
	int ans = 0;
	for (int i = 0; i < cnt.size(); i++)
	{
		int val = 0;
		un.clear();
		for (int p : cnt[i])
			un.insert(p);
		for (int j = i + 1; j < cnt.size(); j++)
		{
			us.clear();
			for (auto p : cnt[j])
			{
				if (un.count(p) == 0)
					us.insert(p);
			}
			ans = max(ans, (int)un.size() + (int)us.size());
		}

	}
	cout << ans;
}


#include <iostream> // includes cin to read from stdin and cout to write to stdout
#include <map>
#include <set>
#include <list>
#include <string>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cassert>
#include <math.h>
#include <iomanip>
#include <limits>

///LLONG_MAX,INT_MA
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;i++)
#define REP(i,n) FOR(i,0,(n)-1)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define sz size()
#define FORA(i,c) REP(i,size(c))

#define itype(c) __typeof((c).begin())
#define FORE(e,c) for(itype(c) e=(c).begin();e!=(c).end();e++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))
#define CLEAR(x,c) memset(x,c,sizeof(x))
#define amfor(Iterator, Container) 	for ( auto Iterator = begin(Container); (Iterator) != end(Container); ++(Iterator) )
#define ramfor(Iterator, Container) for ( auto Iterator = Container.rbegin(); (Iterator) != Container.rend(); ++(Iterator) )
template<class C, class E> inline bool contains(const C& container, const E& element) { return container.find(element) != container.end(); }
#define  NP(nn,ta,a,tb,b) struct nn : pair<ta,tb> { nn():pair<ta,tb>(){}; nn(ta pa,tb pb):pair<ta,tb>(pa,pb){} ta& a(){return first;} tb& b(){return second;} };
template<class T> inline void checkmin(T &a, T b) { if (b < a) a = b; }//asigna en a el minimo
template<class T> inline void checkmax(T &a, T b) { if (b > a) a = b; }//asigna en a el maximo

typedef long long ll;
using namespace std; // since cin and cout are both in namespace std, this saves some text
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

struct Data
{
	ll pos;
	vector<int> killn;
	vector<int> killm;
};
//vector<ll> posv;
vector<ll> gn;
vector<ll> gm;
int n, m;
vector<bool> killedn, killedm;
map<ll, Data> pos;
vector<Data> posv;

ll Count(int p1)
{
	ll total = 0;

	REP(i,posv[p1].killn.size())
	{
		int ntokill = posv[p1].killn[i];
		if (!killedn[ntokill])
		{
			killedn[ntokill] = true;
			++total;
		}
	}
	REP(i, posv[p1].killm.size())
	{
		int mtokill = posv[p1].killm[i];
		if (!killedm[mtokill])
		{
			killedm[mtokill] = true;
			++total;
		}
	}

	return total;

}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << std::setprecision(15);
	cout << std::fixed;
	cin >> n >> m;
	gn= vector<ll>(n);
	gm= vector<ll>(m);
	killedn = vector<bool>(n);
	killedm = vector<bool>(m);

	REP(i, n)
	{
		cin >> gn[i];
		gn[i] *= 2;
	}
	REP(i, m)
	{
		cin >> gm[i];
		gm[i] *= 2;
	}
	REP(i, n)
	{
		REP(j, m)
		{
			ll p = (gn[i] + gm[j]) / 2;
			Data &d = pos[p];
			d.killn.push_back(i);
			d.killm.push_back(j);
			d.pos = p;
		}
	}
	for (auto pp : pos)
	{
		posv.push_back(pp.second);
	}
	//posv = vector<ll>(all(pos));
	ll best = 0;
	REP(i, posv.size())
	{
		FOR(j, i , posv.size() - 1)
		{
			REP(k, n)
				killedn[k] = false;
			REP(k, m)
				killedm[k] = false;
			ll bb = Count(i)+Count(j);
			checkmax(best, bb);
		}

	}
	cout << best;

	return 0;
}


#include <iostream> // includes cin to read from stdin and cout to write to stdout
#include <map>
#include <set>
#include <list>
#include <string>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cassert>
#include <math.h>
#include <iomanip>
#include <limits>

///LLONG_MAX,INT_MA
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;i++)
#define REP(i,n) FOR(i,0,(n)-1)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;i--)
#define sz size()
#define FORA(i,c) REP(i,size(c))

#define itype(c) __typeof((c).begin())
#define FORE(e,c) for(itype(c) e=(c).begin();e!=(c).end();e++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REVERSE(x) reverse(all(x))
#define CLEAR(x,c) memset(x,c,sizeof(x))
#define amfor(Iterator, Container) 	for ( auto Iterator = begin(Container); (Iterator) != end(Container); ++(Iterator) )
#define ramfor(Iterator, Container) for ( auto Iterator = Container.rbegin(); (Iterator) != Container.rend(); ++(Iterator) )
template<class C, class E> inline bool contains(const C& container, const E& element) { return container.find(element) != container.end(); }
#define  NP(nn,ta,a,tb,b) struct nn : pair<ta,tb> { nn():pair<ta,tb>(){}; nn(ta pa,tb pb):pair<ta,tb>(pa,pb){} ta& a(){return first;} tb& b(){return second;} };
template<class T> inline void checkmin(T &a, T b) { if (b < a) a = b; }//asigna en a el minimo
template<class T> inline void checkmax(T &a, T b) { if (b > a) a = b; }//asigna en a el maximo

typedef long long ll;
using namespace std; // since cin and cout are both in namespace std, this saves some text
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

struct Data
{
	ll pos;
	vector<int> killn;
	vector<int> killm;
};
//vector<ll> posv;
vector<ll> gn;
vector<ll> gm;
int n, m;
vector<bool> killedn, killedm;
map<ll, Data> pos;
vector<Data> posv;

ll Count(int p1)
{
	ll total = 0;

	REP(i,posv[p1].killn.size())
	{
		int ntokill = posv[p1].killn[i];
		if (!killedn[ntokill])
		{
			killedn[ntokill] = true;
			++total;
		}
	}
	REP(i, posv[p1].killm.size())
	{
		int mtokill = posv[p1].killm[i];
		if (!killedm[mtokill])
		{
			killedm[mtokill] = true;
			++total;
		}
	}

	return total;

}
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout << std::setprecision(15);
	cout << std::fixed;
	cin >> n >> m;
	gn= vector<ll>(n);
	gm= vector<ll>(m);
	killedn = vector<bool>(n);
	killedm = vector<bool>(m);

	REP(i, n)
	{
		cin >> gn[i];
		gn[i] *= 2;
	}
	REP(i, m)
	{
		cin >> gm[i];
		gm[i] *= 2;
	}
	REP(i, n)
	{
		REP(j, m)
		{
			ll p = (gn[i] + gm[j]) / 2;
			Data &d = pos[p];
			d.killn.push_back(i);
			d.killm.push_back(j);
			d.pos = p;
		}
	}
	for (auto pp : pos)
	{
		posv.push_back(pp.second);
	}
	//posv = vector<ll>(all(pos));
	ll best = 0;
	REP(i, posv.size())
	{
		FOR(j, i + 1, posv.size() - 1)
		{
			REP(k, n)
				killedn[k] = false;
			REP(k, m)
				killedm[k] = false;
			ll bb = Count(i)+Count(j);
			checkmax(best, bb);
		}

	}
	cout << best;

	return 0;
}


//my vegetable has exploded. :(
#include<bits/stdc++.h>
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MM(x,y) memset(x,y,sizeof(x))
#define MCPY(a,b) memcpy(a,b,sizeof(b))
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=b;i>=a;i--)
#define fi first
#define se second
#define int long long
using namespace std;

inline int quickpow(int m,int n,int p){int b=1;while(n){if(n&1)b=b*m%p;n=n>>1;m=m*m%p;}return b;}
inline int getinv(int x,int p){return quickpow(x,p-2,p);}
inline int read(void){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){f=ch=='-'?-1:1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x * f;
}
int a[61],b[61],n,m,ans=0;
map<int, bitset<130> >M;
bitset<130>T;
//map<int, bitset<130> >::iterator it,it2;
///------------------head------------------
signed main(signed argc, char *argv[]){
    n=read(),m=read();
    rep(i,1,n) a[i]=read()*2; rep(i,1,m) b[i]=read()*2;
    rep(i,1,n) rep(j,1,m){M[a[i]+b[j]][i]=1;M[a[i]+b[j]][j+n]=1;}
    //for (it = M.begin(); it != M.end(); it++)
    for(auto i : M)
    {
        //for (it2 = M.begin(); it2 != M.end(); it++)
        for(auto j : M)
        {
            //pair<int, bitset<130> >TT = *it;
            T = i.se | j.se;
            int t = T.count();
            ans = t > ans ? t : ans;
        }
    }
    printf("%lld\n",ans);
 	return 0;
}

/* Examples: */
/*

*/

/*

*/


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    map<ll,ll>v1,v2;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1[temp]++;
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2[temp]++;
    }
    long double fx,gx;
    ll c1,c2,total=0,maxo;
    map<ll,ll>max,may;
    map<long double,ll>mat;
    map<long double,bool> ho_gaya_kya;
    for(pair<ll,ll> i:v1)
    {
        for(pair<ll,ll> j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i.first;
            c2=j.first;
            fx=(c1+c2)/2.0;
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(pair<ll,ll> k:v1)
            {
                for(pair<ll,ll> l:v2)
                {
                    c1=k.first;
                    c2=l.first;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=k.second;max[c1]=1;}
                        if(may[c2]==0)
                        {c+=l.second;may[c2]=1;}
                    }
                }
            }
            mat.clear();
            maxo=0;
            for(pair<ll,ll> k:v1)
            {
                for(pair<ll,ll> l:v2)
                {
                    c1=k.first;
                    c2=l.first;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=k.second;

                    if(may[c2]==0)
                        mat[gx]+=l.second;

                    if(mat[gx]>maxo)maxo=mat[gx];
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,temp,c;
    cin>>n>>m;
    set<int>v1,v2;
    map<int,int>x,y;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        x[temp]++;
    }
    for(int i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        y[temp]++;
    }
    int fx,gx;
    int c1,c2,total=0,maxo;

    map<int,bool> ho_gaya_kya;
    map<int,int>max,may;
    map<int,int>mat;
    for(int i:v1)
    {

        for(int j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            fx=(c1+c2);
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<int,int> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    set<ll>v1,v2;
    map<ll,ll>x,y;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        x[temp]++;
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        y[temp]++;
    }
    long double fx,gx;
    ll c1,c2,total=0,maxo;
    map<ll,ll>max,may;
    map<long double,ll>mat;
    for(ll i:v1)
    {
        for(ll j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            if((c1+c2)%2==1)continue;
            fx=(c1+c2)/2.0;
            for(ll k:v1)
            {
                for(ll l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(ll k:v1)
            {
                for(ll l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<double,ll> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    map<ll,ll>v1,v2;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1[temp]++;
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2[temp]++;
    }
    long double fx,gx;
    ll c1,c2,total=0,maxo,flag;
    map<ll,ll>max,may;
    map<long double,ll>mat;
    map<long double,bool> ho_gaya_kya;
    for(pair<ll,ll> i:v1)
    {
        for(pair<ll,ll> j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i.first;
            c2=j.first;
            fx=(c1+c2)/2.0;
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(pair<ll,ll> k:v1)
            {
                flag=0;
                for(pair<ll,ll> l:v2)
                {
                    c1=k.first;
                    c2=l.first;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=k.second;max[c1]=1;}
                        if(may[c2]==0)
                        {c+=l.second;may[c2]=1;}
                        flag=1;
                    }
                    if(flag==1)break;
                }
            }
            mat.clear();
            maxo=0;
            for(pair<ll,ll> k:v1)
            {
                for(pair<ll,ll> l:v2)
                {
                    c1=k.first;
                    c2=l.first;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=k.second;

                    if(may[c2]==0)
                        mat[gx]+=l.second;

                    if(mat[gx]>maxo)maxo=mat[gx];
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    vector<ll>v1,v2;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1.push_back(temp);
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2.push_back(temp);
    }
    double fx,gx;
    ll c1,c2,total=0,maxo;
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    map<ll,ll>max,may;
    map<double,ll>mat;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            c=0;
            max.clear();
            may.clear();
            c1=v1[i];
            c2=v2[j];
            fx=(c1+c2)/2.0;
            for(ll k=0;k<n;k++)
            {
                for(ll l=0;l<m;l++)
                {
                    c1=v1[k];
                    c2=v2[l];
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        c++;max[c1]=1;
                        c++;may[c2]=1;
                    }
                }
            }
            mat.clear();
            for(ll k=0;k<n;k++)
            {
                for(ll l=0;l<m;l++)
                {
                    c1=v1[k];
                    c2=v2[l];
                    gx=(c1+c2)/2.0;
                    if(max[c1]==0)
                    {
                        mat[gx]++;
                    }
                    if(may[c2]==0)
                    {
                        mat[gx]++;
                    }
                }
            }
            maxo=0;
            for(pair<double,ll> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    map<ll,ll>v1,v2;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1[temp]++;
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2[temp]++;
    }

    long double fx,gx;
    ll c1,c2,total=0,maxo;
    map<ll,ll>max,may;
    map<long double,ll>mat;
    map<long double,bool> ho_gaya_kya;
    for(pair<ll,ll> i:v1)
    {
        for(pair<ll,ll> j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i.first;
            c2=j.first;
            fx=(c1+c2)/2.0;
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(pair<ll,ll> k:v1)
            {
                for(pair<ll,ll> l:v2)
                {
                    c1=k.first;
                    c2=l.first;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=k.second;max[c1]=1;}
                        if(may[c2]==0)
                        {c+=l.second;may[c2]=1;}
                    }
                }
            }
            mat.clear();
            maxo=0;
            for(pair<ll,ll> k:v1)
            {
                for(pair<ll,ll> l:v2)
                {
                    c1=k.first;
                    c2=l.first;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=k.second;

                    if(may[c2]==0)
                        mat[gx]+=l.second;

                    if(mat[gx]>maxo)maxo=mat[gx];
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    vector<ll>v1,v2;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1.push_back(temp);
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2.push_back(temp);
    }
    double fx,gx;
    ll c1,c2,total=0,maxo;
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    map<ll,ll>max,may;
    map<double,ll>mat;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            c=0;
            max.clear();
            may.clear();
            c1=v1[i];
            c2=v2[j];
            fx=(c1+c2)/2.0;
            for(ll k=0;k<n;k++)
            {
                for(ll l=0;l<m;l++)
                {
                    c1=v1[k];
                    c2=v2[l];
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        if(max[k]==0)
                        {
                            c++;max[k]=1;
                        }
                        if(may[l]==0)
                        {
                            c++;may[l]=1;
                        }
                    }
                }
            }
            mat.clear();
            for(ll k=0;k<n;k++)
            {
                for(ll l=0;l<m;l++)
                {
                    c1=v1[k];
                    c2=v2[l];
                    gx=(c1+c2)/2.0;
                    if(max[k]==0)
                    {
                        max[k]=1;
                        mat[gx]++;
                    }
                    if(may[l]==0)
                    {
                        may[l]=1;
                        mat[gx]++;
                    }
                }
            }
            maxo=0;
            for(pair<double,ll> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,temp,c;
    cin>>n>>m;
    set<int>v1,v2;
    map<int,int>x,y;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        ++x[temp];
    }
    for(int i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        ++y[temp];
    }
    int fx,gx;
    int c1,c2,total=0,maxo;

    map<int,bool> ho_gaya_kya;
    map<int,int>max,may;
    map<int,int>mat;
    for(int i:v1)
    {
        for(int j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            fx=(c1+c2);
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<int,int> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,temp,c;
    cin>>n>>m;
    set<int>v1,v2;
    map<int,int>x,y;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        x[temp]++;
    }
    for(int i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        y[temp]++;
    }
    int fx,gx;
    int c1,c2,total=0,maxo;

    map<int,bool> ho_gaya_kya;
    map<int,int>max,may;
    map<int,int>mat;
    for(int i:v1)
    {
        for(int j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            fx=(c1+c2);
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<int,int> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    vector<ll>v1,v2;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1.push_back(temp);
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2.push_back(temp);
    }
    double fx,gx;
    ll c1,c2,total=0,maxo;
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    map<ll,ll>max,may;
    map<double,ll>mat;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            c=0;
            max.clear();
            may.clear();
            c1=v1[i];
            c2=v2[j];
            if((c1+c2)%2==1)continue;
            fx=(c1+c2)/2.0;
            for(ll k=0;k<n;k++)
            {
                for(ll l=0;l<m;l++)
                {
                    c1=v1[k];
                    c2=v2[l];
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        c++;max[c1]=1;
                        c++;may[c2]=1;
                    }
                }
            }
            mat.clear();
            for(ll k=0;k<n;k++)
            {
                for(ll l=0;l<m;l++)
                {
                    c1=v1[k];
                    c2=v2[l];
                    gx=(c1+c2)/2.0;
                    if(max[c1]==0)
                    {
                        mat[gx]++;
                    }
                    if(may[c2]==0)
                    {
                        mat[gx]++;
                    }
                }
            }
            maxo=0;
            for(pair<double,ll> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,temp,c;
    cin>>n>>m;
    set<ll>v1,v2;
    map<ll,ll>x,y;
    for(ll i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        x[temp]++;
    }
    for(ll i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        y[temp]++;
    }
    long double fx,gx;
    ll c1,c2,total=0,maxo;
    map<ll,ll>max,may;
    map<long double,ll>mat;
    for(ll i:v1)
    {
        for(ll j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            fx=(c1+c2)/2.0;
            for(ll k:v1)
            {
                for(ll l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(ll k:v1)
            {
                for(ll l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2)/2.0;
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<double,ll> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,temp,c;
    cin>>n>>m;
    set<int>v1,v2;
    map<int,int>x,y;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        x[temp]++;
    }
    for(int i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        y[temp]++;
    }
    int fx,gx;
    int c1,c2,total=0,maxo;
    map<int,int>max,may;
    map<int,int>mat;
    for(int i:v1)
    {
        for(int j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            fx=(c1+c2);
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<int,int> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,temp,c;
    cin>>n>>m;
    set<int>v1,v2;
    unordered_map<int,int>x,y;
    for(int i=0;i<n;i++)
    {
        cin>>temp;
        v1.insert(temp);
        x[temp]++;
    }
    for(int i=0;i<m;i++)
    {
        cin>>temp;
        v2.insert(temp);
        y[temp]++;
    }
    int fx,gx;
    int c1,c2,total=0,maxo;

    unordered_map<int,bool> ho_gaya_kya;
    unordered_map<int,int>max,may;
    unordered_map<int,int>mat;
    for(int i:v1)
    {
        for(int j:v2)
        {
            c=0;

            max.clear();
            may.clear();
            c1=i;
            c2=j;
            fx=(c1+c2);
            if(ho_gaya_kya[fx]==1)continue;
            ho_gaya_kya[fx]=1;
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)
                    {
                        if(max[c1]==0)
                        {c+=x[c1];max[c1]=1;}
                        if(may[c2]==0)
                        {c+=y[c2];may[c2]=1;}
                    }
                }
            }
            mat.clear();
            for(int k:v1)
            {
                for(int l:v2)
                {
                    c1=k;
                    c2=l;
                    gx=(c1+c2);
                    if(gx==fx)continue;
                    if(max[c1]==0)
                        mat[gx]+=x[c1];

                    if(may[c2]==0)
                        mat[gx]+=y[c2];

                }
            }
            maxo=0;
            for(pair<int,int> v:mat)
            {
                if(v.second>maxo)
                {
                    maxo=v.second;
                }
            }
            if((maxo+c)>total)total=(maxo+c);
        }
    }
    cout<<total;
	// your code goes here
	return 0;
}


// Author: Narut Sereewattanawoot. Email: narut.se@gmail.com //
#include <bits/stdc++.h>
struct CERR_RED {
  template <typename T> CERR_RED& operator<<(T&& t) { std::cerr << "\033[0;31m" << t << "\033[0m"; return *this; }
  CERR_RED& operator<<(std::ostream& (*os)(std::ostream&)) { std::cerr << os; return *this; }
} cerr_red;

#define cerr          cerr_red
#define MOD(i, n)     (((i) % (n) + (n)) % (n))
#define y1            y12345

using Ll = long long;
using namespace std;

int n,m;
unordered_map<int, int> Y, Z;

int Solve()
{
  unordered_set<int> C;
  for(auto &[y, i] : Y) for(auto &[z, j] : Z) C.insert((y+z)/2);
  int ans = 0;
  for(auto c:C)
  {
    unordered_set<int> uY, uZ;
    int base = 0;
    for (auto &[y, i] : Y) {
      auto z = 2*c - y;
      auto it = Z.find(z);
      if (it != end(Z)) {
        base += i + it->second;
        uY.insert(y), uZ.insert(z);
      }
    }
    unordered_map<int, int> inc;
    ans = max(ans, base);
    for (auto [y, i] : Y) {
      for (auto [z, j] : Z) {
        if (uY.count(y)) i = 0;
        if (uZ.count(z)) j = 0;
        if (i == 0 and j == 0) continue;
        auto mid = (y+z)/2;
        inc[mid] += i+j;
        ans = max(ans, base+inc[mid]);
      }
    }
  }
  return ans;
}

int main() {
  #ifdef IDE_TEST_
  #define NAME "io/test"
  freopen(NAME ".in", "r", stdin);
  // freopen(NAME ".out", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  #endif
  cout << fixed << setprecision(10);
  cin>>n>>m;
  for (int i = 0; i < int(n); i++) {
    int y; cin>>y; Y[2*y]++;
  }
  for (int i = 0; i < int(m); i++) {
    int z; cin>>z; Z[2*z]++;
  }
  cout << Solve();
}


// Author: Narut Sereewattanawoot. Email: narut.se@gmail.com //
#include <bits/stdc++.h>
struct CERR_RED {
  template <typename T> CERR_RED& operator<<(T&& t) { std::cerr << "\033[0;31m" << t << "\033[0m"; return *this; }
  CERR_RED& operator<<(std::ostream& (*os)(std::ostream&)) { std::cerr << os; return *this; }
} cerr_red;

#define cerr          cerr_red
#define MOD(i, n)     (((i) % (n) + (n)) % (n))
#define y1            y12345

using Ll = long long;
using namespace std;

int n,m;
map<int, int> Y, Z;

int Solve()
{
  set<int> C;
  for(auto &[y, i] : Y) for(auto &[z, j] : Z) C.insert((y+z)/2);
  int ans = 0;
  for(auto c:C)
  {
    set<int> uY, uZ;
    int base = 0;
    for (auto &[y, i] : Y) {
      auto z = 2*c - y;
      auto it = Z.find(z);
      if (it != end(Z)) {
        base += i + it->second;
        uY.insert(y), uZ.insert(z);
      }
    }
    map<int, int> inc;
    for (auto [y, i] : Y) {
      for (auto [z, j] : Z) {
        if (uY.count(y)) i = 0;
        if (uZ.count(z)) j = 0;
        if (i == 0 and j == 0) continue;
        auto mid = (y+z)/2;
        inc[mid] += i+j;
      }
    }
    ans = max(ans, base);
    for (auto& [_, cnt] : inc) ans = max(ans, base+cnt);
  }
  return ans;
}

int main() {
  #ifdef IDE_TEST_
  #define NAME "io/test"
  freopen(NAME ".in", "r", stdin);
  // freopen(NAME ".out", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  #endif
  cout << fixed << setprecision(10);
  cin>>n>>m;
  for (int i = 0; i < int(n); i++) {
    int y; cin>>y; Y[2*y]++;
  }
  for (int i = 0; i < int(m); i++) {
    int z; cin>>z; Z[2*z]++;
  }
  cout << Solve();
}


// Author: Narut Sereewattanawoot. Email: narut.se@gmail.com //
#include <bits/stdc++.h>
struct CERR_RED {
  template <typename T> CERR_RED& operator<<(T&& t) { std::cerr << "\033[0;31m" << t << "\033[0m"; return *this; }
  CERR_RED& operator<<(std::ostream& (*os)(std::ostream&)) { std::cerr << os; return *this; }
} cerr_red;

#define cerr          cerr_red
#define MOD(i, n)     (((i) % (n) + (n)) % (n))
#define y1            y12345

using Ll = long long;
using namespace std;

int n,m;
map<int, int> Y, Z;
set<int> cand;

int ans;
auto shoot = [] (int y, int c) { return 2*c-y; };
int Solve()
{
  for (auto [y, _] : Y) {
    for (auto [z, _] : Z) cand.insert((y+z)/2);
  }
  for (auto c1 : cand) {
    for (auto c2 : cand) {
      if (c1 == c2) continue;
      bitset<60> shotY = 0, shotZ = 0;
      for (auto [y, i] : Y) {
        auto z1 = shoot(y, c1);
        auto z2 = shoot(y, c2);
        auto it1 = Z.find(z1);
        if (it1 != Z.end()) shotZ[it1->second] = 1, shotY[i] = 1;
        auto it2 = Z.find(z2);
        if (it2 != Z.end()) shotZ[it2->second] = 1, shotY[i] = 1;
      }
      ans = max(ans, int(shotY.count() + shotZ.count()));
    }
  }
  return ans;
}

int main() {
  #ifdef IDE_TEST_
  #define NAME "io/test"
  freopen(NAME ".in", "r", stdin);
  // freopen(NAME ".out", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  #endif
  cout << fixed << setprecision(10);
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) {
    int y; cin >> y; Y.emplace(2*y, i);
  }
  for (int i = 0; i < int(m); i++) {
    int y; cin >> y; Z.emplace(2*y, i);
  }
  cout << Solve();
}


// Author: Narut Sereewattanawoot. Email: narut.se@gmail.com //
#include <bits/stdc++.h>
struct CERR_RED {
  template <typename T> CERR_RED& operator<<(T&& t) { std::cerr << "\033[0;31m" << t << "\033[0m"; return *this; }
  CERR_RED& operator<<(std::ostream& (*os)(std::ostream&)) { std::cerr << os; return *this; }
} cerr_red;

#define cerr          cerr_red
#define MOD(i, n)     (((i) % (n) + (n)) % (n))
#define y1            y12345

using Ll = long long;
using namespace std;

int n, m;
// set<int> Y, Z;
map<int, int> Y, Z;
set<int> cand;

auto shoot = [] (int y, int c) { return 2*c-y; };

int Solve()
{
  int ans = 0;
  for(auto& [y, _]:Y) for (auto& [z, _]:Z) cand.insert((y+z)/2);
  for(auto c:cand)
  {
    bitset<64> Yflag = 0, Zflag = 0;
    for(auto& [y, i]:Y) {
      auto it = Z.find(shoot(y, c));
      if (it != Z.end()) {
        Yflag[i] = 1;
        Zflag[it->second] = 1;
      }
    }
    int base = Yflag.count() + Zflag.count();
    ans = max(ans, base);
    map<int, int> sc;
    for(auto& [y, i]:Y) {
      for (auto& [z, j]:Z) {
        if (Yflag[i] and Zflag[j]) continue;
        int mid = (y+z)/2;
        sc[mid] += 2 - Yflag[i] - Zflag[j];
      }
    }
    for (auto& [_, cnt] : sc) ans = max(ans, base+cnt);
  }
  return ans;
}

int main() {
  #ifdef IDE_TEST_
  #define NAME "io/test"
  freopen(NAME ".in", "r", stdin);
  // freopen(NAME ".out", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  #endif
  cout << fixed << setprecision(10);
  cin>>n>>m;
  for (int i = 0; i < int(n); i++) {
    int y; cin>>y; Y.emplace(2*y, i);
  }
  for (int i = 0; i < int(m); i++) {
    int z; cin>>z; Z.emplace(2*z, i);
  }
  cout << Solve();
}


// Author: Narut Sereewattanawoot. Email: narut.se@gmail.com //
#include <bits/stdc++.h>
struct CERR_RED {
  template <typename T> CERR_RED& operator<<(T&& t) { std::cerr << "\033[0;31m" << t << "\033[0m"; return *this; }
  CERR_RED& operator<<(std::ostream& (*os)(std::ostream&)) { std::cerr << os; return *this; }
} cerr_red;

#define cerr          cerr_red
#define MOD(i, n)     (((i) % (n) + (n)) % (n))
#define y1            y12345

using Ll = long long;
using namespace std;

int n, m;
// set<int> Y, Z;
map<int, int> Y, Z;
set<int> cand;

auto shoot = [] (int y, int c) { return 2*c-y; };

int Solve()
{
  int ans = 0;
  for(auto& [y, _]:Y) for (auto& [z, _]:Z) cand.insert((y+z)/2);
  for(auto c:cand)
  {
    bitset<64> Yflag = 0, Zflag = 0;
    for(auto& [y, i]:Y) {
      auto it = Z.find(shoot(y, c));
      if (it != Z.end()) {
        Yflag[i] = 1;
        Zflag[it->second] = 1;
      }
    }
    int base = Yflag.count() + Zflag.count();
    map<int, int> sc;
    for(auto& [y, i]:Y) {
      for (auto& [z, j]:Z) {
        if (Yflag[i] and Zflag[j]) continue;
        int mid = (y+z)/2;
        sc[mid] += 2 - Yflag[i] - Zflag[j];
      }
    }
    for (auto& [_, cnt] : sc) ans = max(ans, base+cnt);
  }
  return ans;
}

int main() {
  #ifdef IDE_TEST_
  #define NAME "io/test"
  freopen(NAME ".in", "r", stdin);
  // freopen(NAME ".out", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  #endif
  cout << fixed << setprecision(10);
  cin>>n>>m;
  for (int i = 0; i < int(n); i++) {
    int y; cin>>y; Y.emplace(2*y, i);
  }
  for (int i = 0; i < int(m); i++) {
    int z; cin>>z; Z.emplace(2*z, i);
  }
  cout << Solve();
}


// Author: Narut Sereewattanawoot. Email: narut.se@gmail.com //
#include <bits/stdc++.h>
struct CERR_RED {
  template <typename T> CERR_RED& operator<<(T&& t) { std::cerr << "\033[0;31m" << t << "\033[0m"; return *this; }
  CERR_RED& operator<<(std::ostream& (*os)(std::ostream&)) { std::cerr << os; return *this; }
} cerr_red;

#define cerr          cerr_red
#define MOD(i, n)     (((i) % (n) + (n)) % (n))
#define y1            y12345

using Ll = long long;
using namespace std;

int n,m;
map<int, int> Y, Z;
set<int> cand;

int ans;
auto shoot = [] (int y, int c) { return 2*c-y; };
int Solve()
{
  for (auto [y, _] : Y) {
    for (auto [z, _] : Z) cand.insert((y+z)/2);
  }
  for (auto c1 : cand) {
    for (auto c2 : cand) {
      if (c1 == c2) continue;
      bitset<60> shotY = 0, shotZ = 0;
      for (auto [y, _] : Y) {
        auto z1 = shoot(y, c1);
        auto z2 = shoot(y, c2);
        auto it1 = Z.find(z1);
        if (it1 != Z.end()) shotZ[it1->second] = 1;
        auto it2 = Z.find(z2);
        if (it2 != Z.end()) shotZ[it2->second] = 1;
      }
      for (auto [z, _] : Z) {
        auto y1 = shoot(z, c1), y2 = shoot(z, c2);
        auto it1 = Y.find(y1), it2 = Y.find(y2);
        if (it1 != Y.end()) shotY[it1->second] = 1;
        if (it2 != Y.end()) shotY[it2->second] = 1;
      }
      ans = max(ans, int(shotY.count() + shotZ.count()));
    }
  }
  return ans;
}

int main() {
  #ifdef IDE_TEST_
  #define NAME "io/test"
  freopen(NAME ".in", "r", stdin);
  // freopen(NAME ".out", "w", stdout);
  #else
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  #endif
  cout << fixed << setprecision(10);
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) {
    int y; cin >> y; Y.emplace(2*y, i);
  }
  for (int i = 0; i < int(m); i++) {
    int y; cin >> y; Z.emplace(2*y, i);
  }
  cout << Solve();
}