/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    if(a[n]!=a[n-1]) c++;
    if(c<=k)
    {
        cout<<1<<endl;
        return;
    }
    set<ll>s;
    ll j;
    s.insert(a[1]);
    ll ans=1;
    vll v;
    v.pub(a[1]);
    for(i=2;i<=n;i++)
    {
        if(s.count(a[i]))
        {
            continue;
        }
        else
            ans++;
        v.pub(a[i]);
        for(j=0;j<v.size();j++)
            s.insert(v[j]+a[i]);
        s.insert(a[i]);
    }
    //cout<<ans<<endl;
    ans=ceil((ans*1.0)/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]&&a[i]!=0) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=1;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    ll ans=ceil(c*1.0/(k));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    if(c<=k)
    {
        cout<<1<<endl;
        return;
    }
    set<ll>s;
    ll j;
    s.insert(a[1]);
    ll ans=1;
    for(i=2;i<=n;i++)
    {
        if(s.count(a[i]))
        {
            continue;
        }
        else
            ans++;
        vll v;
        v.pub(0);
        for(auto it=s.begin();it!=s.end();it++)
        {
            v.pub(*it);
        }
        for(j=0;j<v.size();j++)
            s.insert(v[j]+a[i]);
    }
    //cout<<ans<<endl;
    ans=ceil((ans*1.0)/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=2;i<=n;i++)
    {
        if(a[i]!=a[i-1]) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    if(c<=k)
    {
        cout<<1<<endl;
        return;
    }
    set<ll>s;
    ll j;
    s.insert(a[1]);
    ll ans=1;
    for(i=2;i<=n;i++)
    {
        if(s.count(a[i]))
        {
            continue;
        }
        else
            ans++;
        vll v;
        v.pub(a[1]);
        for(j=2;j<i;j++)
        {
            if(a[j]==a[j-1])
                continue;
            v.pub(a[j]);
        }
        for(j=0;j<v.size();j++)
            s.insert(v[j]+a[i]);
        s.insert(a[i]);
    }
    //cout<<ans<<endl;
    ans=ceil((ans*1.0)/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k,i;
    cin>>n>>k;
    ll a[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    vll v;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    if(a[n]!=a[n-1]) c++;
    if(c<=k)
    {
        cout<<1<<endl;
        return;
    }
    set<ll>s;
    ll j;
    s.insert(a[1]);
    ll ans=1;
    for(i=2;i<=n;i++)
    {
        if(s.count(a[i]))
        {
            continue;
        }
        else
            ans++;
        vll v;
        v.pub(a[1]);
        for(j=2;j<i;j++)
        {
            if(a[j]==a[j-1])
                continue;
            v.pub(a[j]);
        }
        for(j=0;j<v.size();j++)
            s.insert(v[j]+a[i]);
        s.insert(a[i]);
    }
    //cout<<ans<<endl;
    ans=ceil((ans*1.0)/(k-1));
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


/*
||-----------------------------------||
||        Rahat Khan Pathan          ||
||      BGC Trust University         ||
||       Department of CSE           ||
||-----------------------------------||
*/
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pub push_back
#define pi 3.14159265359
#define pob pop_back
#define puf push_front
#define pof pop_front
#define vi vector<int>
#define vll vector<ll>
#define All(X) (X).begin(),(X).end()
#define Reverse(X) reverse(All(X))
#define Unique(X) (X).erase(unique(All(X)),(X).end()))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define vpair vector<pair<ll,ll>>
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using namespace std;
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll i,a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    if(k==1&&a[1]==a[n])
    {
        cout<<1<<endl;
        return;
    }
    if(k==1&&a[1]!=a[n])
    {
        cout<<-1<<endl;
        return;
    }
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(a[i]!=a[i+1]) c++;
    }
    ll ans=ceil(c*1.0/(k-1));
    if(ans<0) ans=1;
    cout<<ans<<endl;
}
int main()
{
    fast;
    ll t;
    cin>>t;
    while(t--)
    {

        solve();
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,1,101) {
            if(m[i] > 0) {
                noOfDistinct++;
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            cout<<ceil(noOfDistinct / (k - 1));
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,c = 0,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                if(i == 0) {
                    noOfDistinct++;
                }
                else {
                    c++;
                    noOfDistinct++;
                }
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            cout<<ceil((double)c / (k - 1));
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,c = 0,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                if(i == 0) {
                    noOfDistinct++;
                }
                else {
                    c += m[i];
                    noOfDistinct++;
                }
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            cout<<ceil(c / (k - 1));
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                noOfDistinct++;
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            int ans = ceil((double)(noOfDistinct - 1) / (k - 1));
            cout<<ans;
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                noOfDistinct++;
            }
        }
        if(k == 1 && noOfDistinct > k) {
            cout<<"-1";
        }
        else if(noOfDistinct == k) {
            cout<<"1";
        }
        else if(noOfDistinct > k) {
            cout<<"2";
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,c = 0,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                if(i == 0) {
                    noOfDistinct++;
                }
                else {
                    c++;
                    noOfDistinct++;
                }
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            int ans = ceil((double)c / (k - 1));
            if(ans > 2) {
                cout<<"2";
            }
            else {
                cout<<ans;
            }
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                noOfDistinct++;
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            int ans = ceil((double)(noOfDistinct - 1) / (k - 1));
            if(ans == 0) {
                cout<<"1";
            }
            else {
                cout<<ans;
            }
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,noOfDistinct = 0,mn = 101;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            mn = min(mn,a);
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                noOfDistinct++;
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else {
            cout<<ceil(noOfDistinct / (k - 1));
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,c = 0,noOfDistinct = 0;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                if(i == 0) {
                    noOfDistinct++;
                }
                else {
                    c++;
                    noOfDistinct++;
                }
            }
        }
        if(k == 1) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"-1";
            }
        }
        else if(k > 1) {
            cout<<ceil(c / (k - 1));
        }
        cout<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define hypertest ios_base::sync_with_stdio(false); cin.tie(NULL);
#define lp(i,s,e) for(int i = s; i < e; i++)
#define rlp(i,s,e) for(int i = e; i >= s; i--)
#define pb(d) push_back(d)
#define make(a,b) make_pair(a,b)
#define mem(a,v) memset(a,v,sizeof(a))
const ll MOD = 1000000007;

int main() {
    hypertest
    int t;
    cin>>t;
    while(t--) {
        int n,k,a,noOfDistinct = 0,mn = 101;
        cin>>n>>k;
        map<int,int> m;
        lp(i,0,n) {
            cin>>a;
            mn = min(mn,a);
            m[a]++;
        }
        lp(i,0,101) {
            if(m[i] > 0) {
                noOfDistinct++;
            }
        }
        if(k == 1 && noOfDistinct > k) {
            cout<<"-1";
        }
        else if(noOfDistinct == k) {
            cout<<"1";
        }
        else if(noOfDistinct > k && k > 1) {
            cout<<"2";
        }
        else if(noOfDistinct < k) {
            if(noOfDistinct == 1) {
                cout<<"1";
            }
            else {
                cout<<"2";
            }
        }
        cout<<"\n";
    }
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      int mx = 0;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          mx = max(mx, val);
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && mx<=k && k==1)
      {
          cout<<"-1"<<endl;
      }

      else
      {
          int ans = distinct/k;
          if(distinct%k)
          {
              ans++;
          }
          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      int mx = 0;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          mx = max(mx, val);
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && k==1 )
      {
          cout<<"-1"<<endl;
      }
      else

      {
          distinct = distinct;
          int ans = 0;
          while(distinct>0)
          {
              distinct = distinct - k;
              ans++;
              if(distinct>1)
                distinct++;
          }

          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      int mx = 0;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          mx = max(mx, val);
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && k==1 )
      {
          cout<<"-1"<<endl;
      }
      else

      {
          distinct = distinct + (distinct% k);
          int ans = (distinct)/(k);

          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      int mx = 0;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          mx = max(mx, val);
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && mx<=k)
      {
          cout<<"-1"<<endl;
      }
      else if(distinct>k && k==1)
      {
          cout<<"-1"<<endl;
      }
      else
      {
          int ans = distinct/k;
          if(distinct%k)
          {
              ans++;
          }
          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && k==1)
      {
          cout<<"-1"<<endl;
      }
      else
      {
          int ans = distinct/k;
          if(distinct%k)
          {
              ans++;
          }
          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      int mx = 0;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          mx = max(mx, val);
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && mx<=k)
      {
          cout<<"-1"<<endl;
      }
      else
      {
          int ans = distinct/k;
          if(distinct%k)
          {
              ans++;
          }
          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      int mx = 0;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          mx = max(mx, val);
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && k==1 )
      {
          cout<<"-1"<<endl;
      }
      else

      {
          distinct = distinct;
          int ans = (distinct)/(k);
          if(distinct%k)
            ans++;
          if(k==2)
          {
              ans = distinct-1;
          }

          cout<<ans<<endl;

      }

    }
}


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
      int n,k;
      cin>>n>>k;
      int a[105];
      for(int i = 0 ; i<=100; i++)
      {
          a[i] = 0;
      }
     // cout<<"k = "<< k<<endl;
      int distinct = 0, val;
      for(int i = 0 ;i<n; i++)
      {

          cin>>val;
          if(a[val] == 0)
          {
              distinct++;
          }
          a[val]++;
      }
     // cout<<"distinct = "<<distinct<<endl;
      if(distinct>k && val == k)
      {
          cout<<"-1"<<endl;
      }
      else
      {
          int ans = distinct/k;
          if(distinct%k)
          {
              ans++;
          }
          cout<<ans<<endl;

      }

    }
}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
map <int,int> dp;
void solve(){
  int n , k , ans = 0 ;
  cin >> n >> k;

  vector <int> a(n);
  dp.clear();
  set <int> b;

  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 0 ; i < sz(a) ; i++) {
    if(i > 0){if(a[i]==a[i-1]) continue; }
    if(sz(b) == k) break;
    b.insert(a[i]);
  }

  while(sz(b)){
    vector <int> r;
    for(auto x : a){
      int f = 0;
      for(auto c : b){
        if(x == c) f = 1;
      }
      if(!f) r.pb(x);
    }
    a = r;

    for(int i = 0 ; i  < sz(a) ; i++){
      for(auto c : b){
        if(a[i] - c < 0) continue;
        dp[a[i] - c]++;
      }
    }

    for(int i = 0 ; i < sz(a) ; i++){
      int cmax = 0 , cur = a[i];
      for(auto c : b){
        if(a[i] - c < 0) continue;
        if(dp[a[i] - c] > cmax){
          cmax = dp[a[i] - c];
          cur = a[i] - c;
        }
      }
      a[i] = cur;
    }

    sort(all(a));
    b.clear();
    for(auto x : a){
      b.insert(x);
      if(sz(b)==k) break;
    }
    ans++;
    if(sz(b)== 1 && *(b.begin()) == 0) break;
  }

  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

/*
    k = 2
    2 3 5 7 8 10 11 12 14
    2 3 5

    7 - 2 = 5
    7 - 3 = 4
    7 - 5 = 2

    8 - 2 = 6
    8 - 3 = 5
    8 - 5 = 2
    0 0 0 0 0 0 0 0 0 0

    0
*/

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
map <int,int> dp;
void solve(){
  int n , k , ans = 0 , dif = 0;
  cin >> n >> k;
  vector <int> a(n);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  if(a[0]!=a[1]) dif = 1;
  for(int i = 1 ; i < sz(a) ; i++){
    if(a[i]!=a[i-1]){
      dif++;
    }
    if(dif == k){
      ans++;
      dif = 1;
    }
  }
  if(dif > 1) ans++;
  cout << max(1,ans) << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void solve(){
  int n , k , ans = 0 ;
  cin >> n >> k;

  vector <int> a(n) , dp(2*n);
  set <int> b;

  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 0 ; i < sz(a) ; i++) {
    if(a[i] == a[i-1] && i != 0) continue;
    if(sz(b) == k) break;
    b.insert(a[i]);
  }

  while(sz(b)){
    vector <int> r;
    for(auto x : a){
    bool ok = 0;
    for(auto c : b){
    if(x==c) ok = 1;
    }
    if(!ok) r.pb(x);
    }
    a = r;

    for(auto x : a){
      for(auto c : b){
        dp[max(0,x - c)]++;
       }
    }

    for(int i = 0  ; i < sz(a) ; i++){
      int cmax = 0 , cur = a[i];
      for(auto c : b){
        if(a[i] - c < 0) continue;
        if(dp[a[i] - c] > cmax){
          cmax = dp[a[i]- c];
          cur = a[i] - c;
        }
      }
      a[i] = cur;
    }

    sort(all(a));
    b.clear();
    for(int i = 0 ; i < sz(a) ; i++){
      if(a[i] == a[i-1] && i != 0) continue;
      if(sz(b) == k) break;
      b.insert(a[i]);
    }
    // bool ok = 0;
    // for(auto x : b) {if(x!=0) ok = 1;}
    // if(!ok) break;
    ans++;
  }

  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

/*
    k = 2
    2 3 5 7 8 10 11 12 14
    2 3 5

    7 - 2 = 5
    7 - 3 = 4
    7 - 5 = 2

    8 - 2 = 6
    8 - 3 = 5
    8 - 5 = 2
    0 0 0 0 0 0 0 0 0 0

    0
*/

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
map <int,int> dp;
void solve(){
  int n , k , ans = 0 , dif = 0 , ok = 0;
  cin >> n >> k;
  vector <int> a(n);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }
  for(int i = 0 ; i < n - 1 ; i++){
    if(a[i]!=a[i+1]) { ok = 1; }
  }
  if(k==1){
    if(ok) { cout << "-1\n"; return; }
  }
  if(!ok) {
    cout << "1\n";
    return;
  }
  dif = 1;
  for(int i = 1 ; i < sz(a) ; i++){
    if(a[i]!=a[i-1]){
      dif++;
    }
    if(dif == k){
      ans++;
      dif = 1;
    }
  }
  if(dif > 1) ans++;
  cout << max(1,ans) << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void solve(){
  int n , k , ans = 0 ;
  cin >> n >> k;

  vector <int> a(n) , dp(2*n);
  set <int> b;

  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 0 ; i < sz(a) ; i++) {
    if(i > 0){if(a[i]==a[i-1]) continue; }
    if(sz(b) == k) break;
    b.insert(a[i]);
  }

  while(sz(b)){
    vector <int> r;
    for(auto x : a){
      int f = 0;
      for(auto c : b){
        if(x == c) f = 1;
      }
      if(!f) r.pb(x);
    }
    a = r;

    for(int i = 0 ; i  < sz(a) ; i++){
      for(auto c : b){
        dp[a[i] - c]++;
      }
    }

    for(int i = 0 ; i < sz(a) ; i++){
      int cmax = 0 , cur = a[i];
      for(auto c : b){
        if(a[i] - c < 0) continue;
        if(dp[a[i] - c] > cmax){
          cmax = dp[a[i] - c];
          cur = a[i] - c;
        }
      }
      a[i] = cur;
    }

    sort(all(a));
    b.clear();
    for(auto x : a){
      b.insert(x);
      if(sz(b)==k) break;
    }
    ans++;
    if(sz(b)== 1 && *(b.begin()) == 0) break;
  }

  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

/*
    k = 2
    2 3 5 7 8 10 11 12 14
    2 3 5

    7 - 2 = 5
    7 - 3 = 4
    7 - 5 = 2

    8 - 2 = 6
    8 - 3 = 5
    8 - 5 = 2
    0 0 0 0 0 0 0 0 0 0

    0
*/

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
map <int,int> dp;
void solve(){
  int n , k , ans = 0 ;
  cin >> n >> k;

  vector <int> a(n);
  dp.clear();
  set <int> b;

  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 0 ; i < sz(a) ; i++) {
    if(i > 0){if(a[i]==a[i-1]) continue; }
    if(sz(b) == k) break;
    b.insert(a[i]);
  }
  while(sz(b)){
    vector <int> r;
    for(auto x : a){
      int f = 0;
      for(auto c : b){
        if(x == c) f = 1;
      }
      if(!f) r.pb(x);
    }
    a = r;

    for(int i = 0 ; i  < sz(a) ; i++){
      for(auto c : b){
        if(a[i] - c < 0) continue;
        dp[a[i] - c]++;
      }
    }

    for(int i = 0 ; i < sz(a) ; i++){
      int cmax = 0 , cur = a[i];
      for(auto c : b){
        if(a[i] - c < 0) continue;
        if(dp[a[i] - c] > cmax){
          cmax = dp[a[i] - c];
          cur = a[i] - c;
        }
      }
      a[i] = cur;
    }

    sort(all(a));
    b.clear();
    b.insert(0);
    for(auto x : a){
      b.insert(x);
      if(sz(b)==k) break;
    }
    // for(auto x : a){
    //   cout << x << " ";
    // }
    // cout << "\n";
    ans++;
    if(sz(b)== 1 && *(b.begin()) == 0) break;
  }

  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

/*
    k = 2
    2 3 5 7 8 10 11 12 14
    2 3 5

    7 - 2 = 5
    7 - 3 = 4
    7 - 5 = 2

    8 - 2 = 6
    8 - 3 = 5
    8 - 5 = 2
    0 0 0 0 0 0 0 0 0 0

    0
*/

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void solve(){
  int n , k , ans = 0 ;
  cin >> n >> k;

  vector <int> a(n) , dp(2*n);
  set <int> b;

  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 0 ; i < sz(a) ; i++) {
    if(a[i] == a[i-1] && i != 0) continue;
    if(sz(b) == k) break;
    b.insert(a[i]);
  }

  while(sz(b)){
    vector <int> r;
    for(auto x : a){
    bool ok = 0;
    for(auto c : b){
    if(x==c) ok = 1;
    }
    if(!ok) r.pb(x);
    }
    a = r;

    for(auto x : a){
      for(auto c : b){
        dp[max(0,x - c)]++;
       }
    }

    for(int i = 0  ; i < sz(a) ; i++){
      int cmax = 0 , cur = a[i];
      for(auto c : b){
        if(a[i] - c < 0) continue;
        if(dp[a[i] - c] > cmax){
          cmax = dp[a[i]- c];
          cur = a[i] - c;
        }
      }
      a[i] = cur;
    }

    sort(all(a));
    b.clear();
    for(int i = 0 ; i < sz(a) ; i++){
      if(a[i] == a[i-1] && i != 0) continue;
      if(sz(b) == k) break;
      b.insert(a[i]);
    }
    bool ok = 0;
    for(auto x : b) {if(x!=0) ok = 1;}
    if(!ok) break;
    ans++;
  }

  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

/*
    k = 2
    2 3 5 7 8 10 11 12 14
    2 3 5

    7 - 2 = 5
    7 - 3 = 4
    7 - 5 = 2

    8 - 2 = 6
    8 - 3 = 5
    8 - 5 = 2
    0 0 0 0 0 0 0 0 0 0

    0
*/

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
map <int,int> dp;
void solve(){
  int n , k , ans = 1 , dif = 0;
  cin >> n >> k;
  vector <int> a(n);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 1 ; i < sz(a) ; i++){
    if(a[i]!=a[i-1]){
      dif++;
    }
    if(dif == k){
      if(i!=n-1) ans++;
      dif = 1;
    }
  }
  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
void solve(){
  int n , k , ans = 0 ;
  cin >> n >> k;

  vector <int> a(n) , dp(2*n);
  set <int> b;

  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  for(int i = 0 ; i < sz(a) ; i++) {
    if(a[i] == a[i-1] && i != 0) continue;
    if(sz(b) == k) break;
    b.insert(a[i]);
  }

  while(sz(b)){
    vector <int> r;
    for(auto x : a){
    bool ok = 0;
    for(auto c : b){
    if(x==c) ok = 1;
    }
    if(!ok) r.pb(x);
    }
    a = r;
    for(auto x : a){
      for(auto c : b){
        dp[x - c]++;
       }
    }
    for(int i = 0  ; i < sz(a) ; i++){
      int cmax = 0 , cur = a[i];
      for(auto c : b){
        if(dp[a[i] - c] > cmax){
          cmax = dp[a[i]- c];
          cur = a[i] - c;
        }
      }
      a[i] = cur;
    }
    sort(all(a));
    b.clear();
    for(int i = 0 ; i < sz(a) ; i++){
      if(a[i] == a[i-1] && i != 0) continue;
      if(sz(b) == k) break;
      b.insert(a[i]);
    }
    if(sz(b)==1 && *(b.begin()) == 0){
      break;
    }
    ans++;
  }
  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

/*
    k = 2
    2 3 5 7 8 10 11 12 14
    2 3 5

    7 - 2 = 5
    7 - 3 = 4
    7 - 5 = 2

    8 - 2 = 6
    8 - 3 = 5
    8 - 5 = 2
    0 0 0 0 0 0 0 0 0 0

    0
*/

}


//#include <fsociety>
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdio.h>
//end of libraries ;
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// ll lmax(ll o , ll w) {if(o>w)return o; return w;}
// ll lmin(ll o , ll w) {if(o<w)return o; return w;}
#define LNF 3999999999999999999
#define INF 999999999
#define N 3000003
#define PI 3.14159265359
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define ll long long
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define mkp(a,b) make_pair(a,b)
#define rsz(a,n) a.resize(n)
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
map <int,int> dp;
void solve(){
  int n , k , ans = 1 , dif = 0;
  cin >> n >> k;
  vector <int> a(n);
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }

  if(k==1){
    for(int i = 0 ; i < n - 1 ; i++){
      if(a[i]!=a[i+1]) { cout << "-1\n"; return; }
    }
  }
  if(a[0]!=a[1]) dif = 1;
  for(int i = 1 ; i < sz(a) ; i++){
    if(a[i]!=a[i-1]){
      dif++;
    }
    if(dif == k){
      // ans++;
      // cout << i << " ";
      if(i!=n-1) ans++;
      dif = 0;
    }
  }
  cout << ans << "\n";

}

int main(){
fcin;
int t;
cin >> t;
while(t--){
  solve();
}

}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(k==1 && arr[0]!=arr[n-1])
        {
            cout<<-1<<"\n";
            continue;
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        int cnt = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            // deb(st.size());
            if(st.size()==k)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
                break;
            }
            else
            {
                pos++;
            }

        }
        st.clear();
        if(cnt==0) cnt = 1;
        // deb(pos);
        while(pos<n)
        {
            // deb(pos);
            st.insert(arr[pos]);
            if((int)st.size()==k-1)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
            }
            else
            {
                pos++;
            }

        }
        // deb(st.size());
        cnt+=(st.size()>0);
        cout<<cnt<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        int cnt = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            // deb(st.size());
            if(st.size()==k)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
                break;
            }
            else
            {
                pos++;
            }

        }
        st.clear();
        if(cnt==0) cnt = 1;
        // deb(pos);
        while(pos<n)
        {
            // deb(pos);
            st.insert(arr[pos]);
            if((int)st.size()==k-1)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
            }
            else
            {
                pos++;
            }

        }

        cout<<cnt<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            pos++;
            if(st.size()==k)
            {
                break;
            }
        }
        st.clear();
        int cnt = 1;
        // deb(pos);
        while(pos<n)
        {
            // deb(pos);
            st.insert(arr[pos]);
            if((int)st.size()==k-1)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
            }
            else
            {
                pos++;
            }

        }

        cout<<cnt<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st.insert(arr[i1]);
        }
        int s = st.size();
        int ans = (s+k-1)/k;
        if(s>k)
        {
            int mx = *st.rbegin();
            if(mx<=1)
            {
                cout<<-1<<"\n";
            }
            else
            {
                cout<<ans<<"\n";
            }
            continue;
        }
        cout<<ans<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            pos++;
            if(st.size()==k)
            {
                break;
            }
        }
        st.clear();
        int cnt = 1;
        // deb(pos);
        while(pos<n)
        {
            st.insert(arr[pos]);
            bool g = 0;
            while(pos<n && (int)st.size()==k-1)
            {
                // deb(st.size());
                // deb(arr[pos]);
                st.insert(arr[pos]);
                pos++;
                g = 1;
            }
            if(g)
            {
                // deb(pos);
                st.clear();
                st.insert(arr[pos-1]);
                cnt++;
            }
            else
            {
                pos++;
            }

        }
        // deb(st.size());
        cnt+=(st.size()==k-1);
        cout<<cnt<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        int cnt = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            // deb(st.size());
            if(st.size()==k)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
                break;
            }
            else
            {
                pos++;
            }

        }
        st.clear();

        // deb(pos);
        while(pos<n)
        {
            // deb(pos);
            st.insert(arr[pos]);
            if((int)st.size()==k-1)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
            }
            else
            {
                pos++;
            }

        }

        cout<<cnt<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(k==1 && arr[0]==0)
        {
            cout<<-1<<"\n";
            continue;
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        int cnt = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            // deb(st.size());
            if(st.size()==k)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
                break;
            }
            else
            {
                pos++;
            }

        }
        st.clear();
        if(cnt==0) cnt = 1;
        // deb(pos);
        while(pos<n)
        {
            // deb(pos);
            st.insert(arr[pos]);
            if((int)st.size()==k-1)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
            }
            else
            {
                pos++;
            }

        }

        cout<<cnt<<"\n";
    }
    return 0;
}


#include <iostream>
#include <limits.h>
#include <cstdint>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <cstring>
#include <deque>
#include <stack>
#include <queue>
#include <utility>
#include <iomanip>      // std::setprecision
#include <sstream>      // std::stringstream
using namespace std;
typedef long long l1;
typedef long long unsigned int lu1;
typedef long double ld;
#define FIO std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PI acos(-1.0)
#define pb push_back
// #define SORT(A) sort(A.begin(), A.end());
// #define REVERSE(A) reverse(A.begin(), A.end());
#define deb(x) cout << #x << ": " << x << "\n"
#define PrintArray(arr) for(int i=0;i<(int)arr.size();i++)cout<<arr[i]<<" ";cout<<"\n";
#define pii pair<int,int>
#define pll pair<long long int , long long int>
#define puu pair<long long unsigned , long long unsigned>
#define int long long
const int MOD = 1e9+7;

int32_t main()
{
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
    FIO;
    int t;
    t = 1;
    cin>>t;
    for(int tc=0;tc<t;tc++)
    {
        int n, k;
        cin>>n>>k;
        vector<int> arr(n);
        set<int> st, st1;
        for(int i1=0;i1<n;i1++)
        {
            cin>>arr[i1];
            st1.insert(arr[i1]);
        }
        if(k==1 && arr[0]==0)
        {
            cout<<-1<<"\n";
            continue;
        }
        if(arr[n-1]<=1)
        {
            if(st1.size()<=k) cout<<1<<"\n";
            else
            {
                cout<<-1<<"\n";
            }
            continue;
        }
        int pos = 0;
        int cnt = 0;
        while(pos<n)
        {
            st.insert(arr[pos]);
            // deb(st.size());
            if(st.size()==k)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
                break;
            }
            else
            {
                pos++;
            }

        }
        st.clear();
        if(cnt==0) cnt = 1;
        // deb(pos);
        while(pos<n)
        {
            // deb(pos);
            st.insert(arr[pos]);
            if((int)st.size()==k-1)
            {
                int j = pos;
                while(j<n && st.count(arr[j]))
                {
                    j++;
                }
                st.clear();
                cnt++;
                pos = j;
            }
            else
            {
                pos++;
            }

        }
        // deb(st.size());
        cnt+=(st.size()>0);
        cout<<cnt<<"\n";
    }
    return 0;
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            int a = SZ(S) - k, b = k - 1;
            cout << 1 + (a > 0 ? a / b + (a % b > 0) : 0) << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1 - (zeroes > 0);
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            int m = 0;
            for (int j = 0; j < n; j++) {
                if (a[j] > i + 1) {
                    m++;
                }
            }
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    S.erase(a[j]);
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 == m && can == 0 && SZ(S) == 1) {
                        can++;
                    }
                }
            }
        }
        cout << min(*max_element(a.begin(), a.end()), n / k + (n % k > 0)) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            int res = 1, left = SZ(S) - k;
            while (left > 0) {
                res++, left -= k - 1;
            }
            cout << res << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        n = SZ(S);
        cout << (n - k) / (k - 1) + 1 + ((n - k) % (k - 1) > 0) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1;
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        reverse(a.begin(), a.end());
        n = SZ(a);
        for (int i = 0; i < n; i++) {
            int can = k - 1;
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            cout << 1 + (int) ceil((SZ(S) - k) / (k - 1)) << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            int a = SZ(S) - k, b = k - 1;
            cout << 1 + a / b + (a % b > 0) << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int ones = n - zeroes;
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 == n && can == 0) {
                        can++;
                    }
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1 - (zeroes > 0);
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int ones = n - zeroes;
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 + (zeroes > 0) == n) {
                        can++;
                    }
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            int m = 0;
            for (int j = 0; j < n; j++) {
                if (a[j] > a[j + 1]) {
                    m++;
                }
            }
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 == m && can == 0) {
                        can++;
                    }
                }
            }
        }
        cout << min(*max_element(a.begin(), a.end()), n / k + (n % k > 0)) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            int m = 0;
            for (int j = 0; j < n; j++) {
                if (a[j] > i + 1) {
                    m++;
                }
            }
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 == m && can == 0) {
                        can++;
                    }
                }
            }
        }
        cout << min(*max_element(a.begin(), a.end()), n / k + (n % k > 0)) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            cout << (SZ(S) - k) / (k - 1) + 1 << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int ones = n - zeroes;
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 + (zeroes > 0) == n && can == 0) {
                        can++;
                    }
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            int res = 1, left = SZ(S) - k;
            while (left > 0) {
                res++, left -= (k - 1);
            }
            cout << res << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        set<int> S;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            S.insert(x);
        }
        if (k == 1) {
            cout << (SZ(S) == 1 ? 1 : -1) << "\n";
        } else {
            cout << SZ(S) / (k - 1) << "\n";
        }
    }
}


#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int T; cin >> T;
    while (T--) {
        int n, k; cin >> n >> k;
        int zeroes = 0;
        vector<int> a;
        for (int i = 0; i < n; i++) {
            int x; cin >> x;
            if (x != 0) {
                a.push_back(x);
            } else {
                zeroes++;
            }
        }
        if (a.empty() || count(a.begin(), a.end(), a[0]) == n) {
            cout << "1\n";
            continue;
        }
        if (zeroes > 0 && k == 1) {
            cout << "-1\n";
            continue;
        }
        set<int> S;
        for (int x : a) {
            S.insert(x);
        }
        a.clear();
        for (int x : S) {
            a.push_back(x);
        }
        n = SZ(a);
        reverse(a.begin(), a.end());
        for (int i = 0; i <= 200; i++) {
            int can = k - 1 - (zeroes > 0);
            int done = 0;
            int m = 0;
            for (int j = 0; j < n; j++) {
                if (a[j] > a[j + 1]) {
                    m++;
                }
            }
            for (int j = 0; j < n && can; j++) {
                if (a[j] > i + 1) {
                    a[j] = i + 1;
                    can--;
                    done++;
                    if (done + 1 == m && can == 0) {
                        can++;
                    }
                }
            }
        }
        cout << *max_element(a.begin(), a.end()) << "\n";
    }
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#define TEST_CASES
#define ONLINE_JUDGE

#define test   \
  long long t; \
  cin >> t;    \
  while (t--)
#ifndef ONLINE_JUDGE
#define reach(x) cout << "\n\t\t" << x << "\n\n";
#define deb(x) cout << #x << " " << x << '\n';
#define deb2(x, y) cout << #x << " --> " << x << " || " << #y << " --> " << y << '\n';
#define deb4(a, b, c, d) cout << #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << '\n';
#else
#define reach(x)         //
#define deb(x)           //cout << #x << " " << x << '\n';
#define deb2(x, y)       //cout << #x << " --> " << x << " || " << #y << " --> " << y <<'\n';
#define deb4(a, b, c, d) // cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<", "<<#d<<" = "<<d<<'\n';
#endif
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; i < n; i++)
#define boost()                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);                      \
  cout << fixed << setprecision(11);
#define MEM(a, val) memset(a, val, sizeof(a));
#define inputarr(a, n)        \
  for (int i = 0; i < n; ++i) \
  cin >> a[i]

const long INF = LONG_LONG_MAX, MOD = 1e9 + 7;

typedef long long ll;
typedef long double ld;
using namespace std;

void solve()
{
  ll n, i, j, k;
  cin >> n >> k;
  vector<ll> a(n);
  inputarr(a, n);
  //logic start

  unordered_set<ll> mp;
  mp.clear();
  for (ll x : a)
    mp.insert(x);
  if (k >= mp.size())
  {
    cout << 1;
    return;
  }
  if (mp.count(0) == 1 && mp.size() > 1 && k == 1)
  {
    cout << -1;
    return;
  }
  i = (mp.size() + k - 1) / k;
  deb2(mp.size(), i);
  if (k == 1)
    for (auto x : mp)
    {
      if (x <= i)
      {
        cout << -1;
        return;
      }
    }
  cout << i;
  return;
}

signed main()
{
#ifdef ONLINE_JUDGE
  boost()
#endif
#ifdef TEST_CASES
      test
#endif
  {
    solve();
#ifdef TEST_CASES
    cout << '\n';
#endif
  }

  return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#define TEST_CASES
#define ONLINE_JUDGE

#define test   \
  long long t; \
  cin >> t;    \
  while (t--)
#ifndef ONLINE_JUDGE
#define reach(x) cout << "\n\t\t" << x << "\n\n";
#define deb(x) cout << #x << " " << x << '\n';
#define deb2(x, y) cout << #x << " --> " << x << " || " << #y << " --> " << y << '\n';
#define deb4(a, b, c, d) cout << #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << '\n';
#else
#define reach(x)         //
#define deb(x)           //cout << #x << " " << x << '\n';
#define deb2(x, y)       //cout << #x << " --> " << x << " || " << #y << " --> " << y <<'\n';
#define deb4(a, b, c, d) // cout<<#a<<" = "<<a<<", "<<#b<<" = "<<b<<", "<<#c<<" = "<<c<<", "<<#d<<" = "<<d<<'\n';
#endif
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; i < n; i++)
#define boost()                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);                      \
  cout << fixed << setprecision(11);
#define MEM(a, val) memset(a, val, sizeof(a));
#define inputarr(a, n)        \
  for (int i = 0; i < n; ++i) \
  cin >> a[i]

const long INF = LONG_LONG_MAX, MOD = 1e9 + 7;

typedef long long ll;
typedef long double ld;
using namespace std;

void solve()
{
  ll n, i, j, k;
  cin >> n >> k;
  vector<ll> a(n);
  inputarr(a, n);
  //logic start

  unordered_set<ll> mp;
  mp.clear();
  for (ll x : a)
    mp.insert(x);
  if (k >= mp.size())
  {
    cout << 1;
    return;
  }
  if (mp.count(0) == 1 && mp.size() > 1 && k == 1)
  {
    cout << -1;
    return;
  }
  i = (mp.size() + k - 1) / k;
  deb2(mp.size(), i);
  if (k == 1)
    for (auto x : mp)
    {
      if (x < i)
      {
        cout << -1;
        return;
      }
    }
  cout << i;
  return;
}

signed main()
{
#ifdef ONLINE_JUDGE
  boost()
#endif
#ifdef TEST_CASES
      test
#endif
  {
    solve();
#ifdef TEST_CASES
    cout << '\n';
#endif
  }

  return 0;
}