#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <iterator>
#include <map>
#include <functional>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <unordered_map>

#define ll long long
#define ld long double
#define y1 abc
#define endl '\n'
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000
#define MINLL -9000000000000000000LL
#define MININT -2000000000
#define stoi aaaaavasd
#define pll pair < ll, ll >

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ld pi = acos(-1);
const ll md = 1e9 + 7;

ll n, i, a[100501], k, mxk;

vector < pll > ans;

vector < ll > t, o;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (i = 1; i <= n; i++){
        cin >> a[i];

        if (a[i] == 1) o.pb(i);
        else if (a[i] == 3) t.pb(i);
    }

    k = 1;

    if (t.size() > 1) for (i = 0; i < t.size() - 1; i++){
        ans.pb({k, t[i]});
        ans.pb({k, t[i + 1]});

        k++;
    }

    if (t.size() >= 1){
        ans.pb({k, t.back()});

        bool f = false;

        for (i = t.back() + 1; i <= n; i++){
            if (a[i] == 2){
                f = true;
                ans.pb({k, i});

                break;
            }
        }

        if (!f){
            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, o.back()});
            ans.pb({k + 1, o.back()});
            o.pop_back();
        }
    }

    if (k != 0) mxk = k;
    else mxk = -1;

    reverse(o.begin(), o.end());

    t.clear();

    k = n;

    for (i = 1; i <= n; i++){
        if (a[i] == 2){
            while (!o.empty() && o.back() < i){
                t.pb(o.back());
                o.pop_back();
            }

            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, i});
            ans.pb({k, o.back()});
            o.pop_back();
            k--;
        }
    }

    for (ll x : o){
        ans.pb({k, x});
        k--;
    }

    for (ll x : t){
        ans.pb({k, x});
        k--;
    }

    if (k <= mxk){
        cout << -1 << endl;

        return 0;
    }

    cout << ans.size() << endl;

    for (pll x : ans) cout << x.fi << " " << x.se << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <iterator>
#include <map>
#include <functional>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <unordered_map>

#define ll long long
#define ld long double
#define y1 abc
#define endl '\n'
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000
#define MINLL -9000000000000000000LL
#define MININT -2000000000
#define stoi aaaaavasd
#define pll pair < ll, ll >

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ld pi = acos(-1);
const ll md = 1e9 + 7;

ll n, i, a[100501], k;

vector < pll > ans;

vector < ll > t, o;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (i = 1; i <= n; i++){
        cin >> a[i];

        if (a[i] == 1) o.pb(i);
        else if (a[i] == 3) t.pb(i);
    }

    k = 1;

    if (t.size() > 1) for (i = 0; i < t.size() - 1; i++){
        ans.pb({k, t[i]});
        ans.pb({k, t[i + 1]});

        k++;
    }

    if (t.size() >= 1){
        ans.pb({k, t.back()});

        bool f = false;

        for (i = t.back() + 1; i <= n; i++){
            if (a[i] == 2){
                f = true;
                ans.pb({k, i});

                break;
            }
        }

        if (!f){
            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, o.back()});
            ans.pb({k + 1, o.back()});
            o.pop_back();
        }
    }

    reverse(o.begin(), o.end());

    k = n;

    for (i = 1; i <= n; i++){
        if (a[i] == 2){
            while (!o.empty() && o.back() < i) o.pop_back();

            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, i});
            ans.pb({k, o.back()});
            o.pop_back();
            k--;
        }
    }

    for (ll x : o){
        ans.pb({k, x});
        k--;
    }

    cout << ans.size() << endl;

    for (pll x : ans) cout << x.fi << " " << x.se << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <iterator>
#include <map>
#include <functional>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <unordered_map>

#define ll long long
#define ld long double
#define y1 abc
#define endl '\n'
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000
#define MINLL -9000000000000000000LL
#define MININT -2000000000
#define stoi aaaaavasd
#define pll pair < ll, ll >

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ld pi = acos(-1);
const ll md = 1e9 + 7;

ll n, i, a[100501], k, mxk;

vector < pll > ans;

vector < ll > t, o;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (i = 1; i <= n; i++){
        cin >> a[i];

        if (a[i] == 1) o.pb(i);
        else if (a[i] == 3) t.pb(i);
    }

    k = 1;

    if (t.size() > 1) for (i = 0; i < t.size() - 1; i++){
        ans.pb({k, t[i]});
        ans.pb({k, t[i + 1]});

        k++;
    }

    if (t.size() >= 1){
        ans.pb({k, t.back()});

        bool f = false;

        for (i = t.back() + 1; i <= n; i++){
            if (a[i] == 2){
                f = true;
                ans.pb({k, i});

                break;
            }
        }

        if (!f){
            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, o.back()});
            ans.pb({k + 1, o.back()});
            o.pop_back();
        }
    }

    if (k != 1) mxk = k;
    else mxk = -1;

    reverse(o.begin(), o.end());

    t.clear();

    k = n;

    for (i = 1; i <= n; i++){
        if (a[i] == 2){
            while (!o.empty() && o.back() < i){
                t.pb(o.back());
                o.pop_back();
            }

            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, i});
            ans.pb({k, o.back()});
            o.pop_back();
            k--;
        }
    }

    for (ll x : o){
        ans.pb({k, x});
        k--;
    }

    for (ll x : t){
        ans.pb({k, x});
        k--;
    }

    if (k <= mxk){
        cout << -1 << endl;

        return 0;
    }

    cout << ans.size() << endl;

    for (pll x : ans) cout << x.fi << " " << x.se << endl;

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <ctime>
#include <vector>
#include <set>
#include <iterator>
#include <map>
#include <functional>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <unordered_map>

#define ll long long
#define ld long double
#define y1 abc
#define endl '\n'
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define MAXLL 9000000000000000000LL
#define MAXINT 2000000000
#define MINLL -9000000000000000000LL
#define MININT -2000000000
#define stoi aaaaavasd
#define pll pair < ll, ll >

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update > ordered_set;

const ld pi = acos(-1);
const ll md = 1e9 + 7;

ll n, i, a[100501], k, mxk;

vector < pll > ans;

vector < ll > t, o;

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n;

    for (i = 1; i <= n; i++){
        cin >> a[i];

        if (a[i] == 1) o.pb(i);
        else if (a[i] == 3) t.pb(i);
    }

    k = 1;

    if (t.size() > 1) for (i = 0; i < t.size() - 1; i++){
        ans.pb({k, t[i]});
        ans.pb({k, t[i + 1]});

        k++;
    }

    if (t.size() >= 1){
        ans.pb({k, t.back()});

        bool f = false;

        for (i = t.back() + 1; i <= n; i++){
            if (a[i] == 2){
                f = true;
                ans.pb({k, i});

                break;
            }
        }

        if (!f){
            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            if (o.back() < t.back()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, o.back()});
            ans.pb({k + 1, o.back()});
            k++;
            o.pop_back();
        }
    }

    reverse(o.begin(), o.end());

    t.clear();

    k = n;

    for (i = 1; i <= n; i++){
        if (a[i] == 2){
            while (!o.empty() && o.back() < i){
                t.pb(o.back());
                o.pop_back();
            }

            if (o.empty()){
                cout << -1 << endl;

                return 0;
            }

            ans.pb({k, i});
            ans.pb({k, o.back()});
            o.pop_back();
            k--;
        }
    }

    for (ll x : o){
        ans.pb({k, x});
        k--;
    }

    for (ll x : t){
        ans.pb({k, x});
        k--;
    }

    cout << ans.size() << endl;

    for (pll x : ans) cout << x.fi << " " << x.se << endl;

    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int last = n;
    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                    break;
                }
            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
            last = j - 1;
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , i});
                    ok = true;
                    break;
                }
                else if(a[j] == 2)
                {
                    res.push_back({i , i});
                    res.push_back({j , i});
                    ok = true;
                    break;
                }

            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
            last = j - 1;
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << x.second << ' ' << x.first << endl;
    }
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int last = n;
    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                    break;
                }
            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
            last = j - 1;
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , i});
                    ok = true;
                    break;
                }
                else if(a[j] == 2 || a[j] == 3)
                {
                    res.push_back({i , i});
                    res.push_back({j , i});
                    ok = true;
                    break;
                }

            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
            last = j - 1;
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << x.second << ' ' << x.first << endl;
    }
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = n ; j > i ; j--)
            {
                if(!st[j] && a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                    break;
                    st[j] = true;
                }
            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = n ; j > i ; j--)
            {
                if(!st[j] && a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , i});
                    st[j] = true;
                    ok = true;
                    break;
                }
                else if(!st[j] && a[j] == 2 || a[j] == 3)
                {
                    st[j] = true;
                    res.push_back({i , i});
                    res.push_back({j , i});
                    ok = true;
                    break;
                }

            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << x.second << ' ' << x.first << endl;
    }
}


#include <iostream>
#include <vector>

#define fi first
#define se second

using namespace std ;

const int N = 1e5+10 ;

using PII = pair<int,int> ;

int arr[N] ;

int main()
{
    int n ;
    cin >> n ;
    for(int i = 1 ; i <= n ; ++i)   cin >> arr[i] ;

    int a = 0 , b = 0 , c = 0 ;
    vector<int> one , two , three ;

    bool flag = true ;
    for(int i = n ; i > 0 ; --i)    //存储所在列
    {
        if(arr[i] == 1)
            one.push_back(i) ;

        if(arr[i] == 2)
            two.push_back(i) ;

        if(arr[i] == 3)
            three.push_back(i) ;

        if(one.size() < two.size() || one.size() < three.size())
        {
            flag = false ;
            break ;
        }
    }

    if(flag){
        a = one.size() , b = two.size() , c = three.size() ;

        vector<PII> ans ;

        int row = n ;
        for(int i = 0 , j = 0 , k = 0 ; i < a ; ++i)
        {
            if(j < b && k < c){
                if(two[j] > three[k]){
                    ans.push_back({row , one[i]}) ;
                    ans.push_back({row , two[j]}) ;
                    --row ;
                    ans.push_back({row , two[j]}) ;
                    ans.push_back({row , three[k]}) ;
                    --row ;
                    ++j , ++k ;
                }else{
                    ans.push_back({row , one[i]}) ;
                    --row ;
                    ans.push_back({row , one[i]}) ;
                    ans.push_back({row , three[k]}) ;
                    --row ;
                    ++k ;
                }
            }else if(j < b){
                ans.push_back({row , one[i]}) ;
                ans.push_back({row , two[j]}) ;
                --row ;
                ++j ;
            }else if(k < c){
                ans.push_back({row , one[i]}) ;
                --row ;
                ans.push_back({row , one[i]}) ;
                ans.push_back({row , three[k]}) ;
                --row ;
                ++k ;
            }else{
                ans.push_back({row , one[i]}) ;
                --row ;
            }

        }

        cout << ans.size() << endl;
        for(auto &x : ans)
            cout << x.fi << ' ' << x.se << endl;
        cout << endl;

    }else{
        cout << -1 << endl;
    }
    return 0 ;
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int last = n;
    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                }
                if(!ok)
                {
                    //cout << i << endl;
                    flag = false;
                    break;
                }
                last = j - 1;
            }
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , j});
                    ok = true;
                    break;
                }
                if(!ok)
                {
                    //cout << i << endl;
                    flag = false;
                    break;
                }
            }
            last = j - 1;
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << 7 - x.second << ' ' << x.first << endl;
    }
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;
vector<int> s[4];

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i}) , s[1].push_back(i);
        else if(a[i] == 2)
        {
            s[2].push_back(i);
            if(s[1].size())
            {
                int j = s[1].back();
                s[1].pop_back();
                res.push_back({i , j});
            }
            else
            {
                flag = false;
                break;
            }
        }
        else if(a[i] == 3)
        {
            int j = -1;
            if(s[3].size())
            {
                j = s[3].back();
                s[3].pop_back();
            }
            else if(s[2].size())
            {
                j = s[2].back();
                s[2].pop_back();
            }
            else if(s[1].size())
            {
                j = s[1].back();
                s[1].pop_back();
            }

            if(~j)
            {
                res.push_back({i , i});
                res.push_back({j , i});
            }
            else
            {
                flag = false;
                break;
            }
            s[3].push_back(i);
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << x.second << ' ' << x.first << endl;
    }
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = n ; j > i ; j--)
            {
                if(!st[j] && a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                    st[j] = true;
                    break;
                }
            }
            if(!ok)
            {
                flag = false;
                break;
            }
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = n ; j > i ; j--)
            {
                if(!st[j] && a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , i});
                    st[j] = true;
                    ok = true;
                    break;
                }
                else if(!st[j] && (a[j] == 2 || a[j] == 3))
                {
                    st[j] = true;
                    res.push_back({i , i});
                    res.push_back({j , i});
                    ok = true;
                    break;
                }
            }
            if(!ok)
            {
                flag = false;
                break;
            }
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << x.second << ' ' << x.first << endl;
    }
}


#include <iostream>
#include <vector>

#define fi first
#define se second

using namespace std ;

const int N = 1e5+10 ;

using PII = pair<int,int> ;

int arr[N] ;

int main()
{
    int n ;
    cin >> n ;
    for(int i = 1 ; i <= n ; ++i)   cin >> arr[i] ;

    int a = 0 , b = 0 , c = 0 ;
    vector<int> one , two , three ;

    bool flag = true ;
    for(int i = n ; i > 0 ; --i)    //存储所在列
    {
        if(arr[i] == 1)
            one.push_back(i) ;

        if(arr[i] == 2)
            two.push_back(i) ;

        if(arr[i] == 3)
            three.push_back(i) ;

        if(one.size() < two.size() || one.size() < three.size())
        {
            flag = false ;
            break ;
        }
    }

    if(flag){
        a = one.size() , b = two.size() , c = three.size() ;

        vector<PII> ans ;

        //for(int i = 0 ; i < a ; ++i)    cout << one[i] << ' ' ; cout << endl;
        int row = n ;
        int i ;
        for(i = 0 ; i < min(b,c) ; ++i)
        {
            ans.push_back({row , one[i]}) ;
            ans.push_back({row , two[i]}) ;
            row-- ;
            ans.push_back({row , one[i]}) ;
            ans.push_back({row , three[i]}) ;
            row-- ;
        }

        for( ; i < b ; ++i)
        {
            ans.push_back({row , one[i]}) ;
            ans.push_back({row , two[i]}) ;
            row-- ;

        }

        for( ; i < c ; ++i)
        {
            ans.push_back({row , one[i]}) ;
            ans.push_back({row , three[i]}) ;
            row-- ;
        }

        for( ; i < a ; ++i)
            ans.push_back({row-- , one[i]}) ;

        cout << ans.size() << endl;
        for(auto &x : ans)
            cout << x.fi << ' ' << x.se << endl;
        cout << endl;

    }else{
        cout << -1 << endl;
    }
    return 0 ;
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int last = n;
    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                }
                if(!ok)
                {
                    //cout << i << endl;
                    flag = false;
                    break;
                }
                last = j - 1;
            }
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , j});
                    ok = true;
                    break;
                }
                if(!ok)
                {
                    //cout << i << endl;
                    flag = false;
                    break;
                }
            }
            last = j - 1;
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << x.first << ' ' << x.second << endl;
    }
}


#include <iostream>
#include <vector>

using namespace std;

const int N = 100010;

int a[N];
bool st[N];
int n;
vector<pair<int , int>> res;

int main()
{
    cin >> n;

    bool flag = true;

    for(int i = 1 ; i <= n ; i++)   cin >> a[i];

    int last = n;
    int j;
    for(int i = n ; i >= 1 ; i--)
    {
        if(a[i] == 1)
            res.push_back({i , i});
        else if(a[i] == 2)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({i , j});
                    ok = true;
                    break;
                }
            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
            last = j - 1;
        }
        else if(a[i] == 3)
        {
            bool ok = false;
            for(j = last ; j > i ; j--)
            {
                if(a[j] == 1)
                {
                    res.push_back({j , i});
                    res.push_back({i , j});
                    ok = true;
                    break;
                }

            }
            if(!ok)
            {
                //cout << i << endl;
                flag = false;
                break;
            }
            last = j - 1;
        }
    }

    if(!flag) puts("-1");
    else
    {
        cout << res.size() << endl;
        for(auto x : res) cout << 7 - x.second << ' ' << x.first << endl;
    }
}


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << endl
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO
using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
/* ---------------- constants ---------------- */
const ll MAXn=2e5 + 33,MAXlg=__lg(MAXn)+2;
const ll mod=1e9 + 7;
const ll INF=ll(1e15);
const ll PI = acosl(-1.0);

/* ---------------- utility functions ---------------- */
int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
int drr[] = {-2,-1,0,1,2};
int dcc[] = {-2,-1,0,1,2};
bool chk(int a, int b, int n, int m) {
    return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
    ll a = 1;
    while (m > 0){
        if (m&1) a = (a * n%md) % md;
        m /= 2;
        n = (n*n) % md;
    }
    return a % md;
}

ll expm(ll n, ll m){
    ll a = 1;
    while (m > 0){
        if(a < 0 or a >= (1e18 + n-1)/n) {
            return -1;
        }
        if (m&1) a = (a * n);
        m /= 2;
        n = (n*n);
    }
    return a;
}

void disp(vi v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
    if(x < 0)
        return -1;
    int l = sqrt(x);
    for (int i = -2; i <= 2; ++i)
        if (l + i >= 0 && (l + i) * (l + i) == x)
            return l;
    return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
    assert(n <= NPRR);
    lp.assign(n+1, 0);
    int i;
    for (i = 2;i <= n;++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            prr.push_back(i);
        }
        for (int u: prr) {
            if(i * u > n || u > lp[i]) break;
            lp[i * u] = u;
        }
    }
}
ll fact[300001],infac[300001];
ll fe(ll a,ll b){
    ll temp=a;
    ll ans=1ll;
    while(b){
        if(b&1){
            ans*=(ll)temp;
            ans%=mod;
        }
        b/=2ll;
        temp=temp*(ll)temp;
        temp%=mod;
    }
    ans += mod;
    ans %= mod;
    return ans%mod;
}
ll mi(ll a){
    return(fe(a,mod-2));
}

void fac(){
    fact[0]=1;
    infac[0]=1;
    forsn(i,1,2009){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        infac[i]=mi(fact[i]);
        infac[i]%=mod;
    }
}
ll ncr(ll a,ll b){
    if(a<b || a<=0)return 0;
    ll ans=fact[a];
    ans*=infac[b];
    ans%=mod;
    ans*=infac[a-b];
    ans%=mod;
    return ans;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

auto random_address = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

/* ---------------- start of code ---------------- */

void go() {
    int n;cin >> n;
    int a[n];
    forn(i,n)cin >> a[i];
    int cnt[4] =  {0};
    for(int i =n-1;i >= 0;i--) {

        cnt[a[i]]++;
        if(cnt[2] + (cnt[3] > 0) > cnt[1]) {
            cout << -1 << ln;
            return;
        }
    }
    queue<int> q;
    queue<int> w;
    vector<pll> ans;
    int id = 0;
    int ok[100005] = {-1};
    for(int i = n-1; i >= 0;i--) {
        if(a[i] == 1 ) {
            q.push(i);
            continue;
        }
        if(a[i] == 2){
            assert(!q.empty());
            ans.pb({i+1, ++id});
            ans.pb({q.front() + 1, id});
            ok[i] = id-1;
            ok[q.front()] =id-1;
            q.pop();
            continue;
        }
        if(a[i] == 3) {
            assert(!(q.empty() and w.empty()));
            if(!w.empty()) {
                ans.pb({i+1, ++id});
                ans.pb({w.front() +1, id});
                ok[i] = id-1;

            }else {
                ans.pb({q.front()+1, ++id});
                ans.pb({i+1, ++id});
                ans.pb({q.front()+1, id});
                ok[i] = id-1;
                ok[q.front()] = id-1;
                q.pop();
            }
            w.push(i);
        }
    }
    while(!q.empty()) {
        ans.pb({q.front()+1, ++id});
        q.pop();
    }
    cout << ans.size() << ln;
    sort(all(ans));
    forn(i, ans.size()) {
        out2(ans[i].S, ans[i].F);
    }

}

int main(){
    fio;
    fflush(stdout);
    cout<<fixed<<setprecision(11);
    cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << endl
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO
using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
/* ---------------- constants ---------------- */
const ll MAXn=2e5 + 33,MAXlg=__lg(MAXn)+2;
const ll mod=1e9 + 7;
const ll INF=ll(1e15);
const ll PI = acosl(-1.0);

/* ---------------- utility functions ---------------- */
int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
int drr[] = {-2,-1,0,1,2};
int dcc[] = {-2,-1,0,1,2};
bool chk(int a, int b, int n, int m) {
    return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
    ll a = 1;
    while (m > 0){
        if (m&1) a = (a * n%md) % md;
        m /= 2;
        n = (n*n) % md;
    }
    return a % md;
}

ll expm(ll n, ll m){
    ll a = 1;
    while (m > 0){
        if(a < 0 or a >= (1e18 + n-1)/n) {
            return -1;
        }
        if (m&1) a = (a * n);
        m /= 2;
        n = (n*n);
    }
    return a;
}

void disp(vi v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
    if(x < 0)
        return -1;
    int l = sqrt(x);
    for (int i = -2; i <= 2; ++i)
        if (l + i >= 0 && (l + i) * (l + i) == x)
            return l;
    return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
    assert(n <= NPRR);
    lp.assign(n+1, 0);
    int i;
    for (i = 2;i <= n;++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            prr.push_back(i);
        }
        for (int u: prr) {
            if(i * u > n || u > lp[i]) break;
            lp[i * u] = u;
        }
    }
}
ll fact[300001],infac[300001];
ll fe(ll a,ll b){
    ll temp=a;
    ll ans=1ll;
    while(b){
        if(b&1){
            ans*=(ll)temp;
            ans%=mod;
        }
        b/=2ll;
        temp=temp*(ll)temp;
        temp%=mod;
    }
    ans += mod;
    ans %= mod;
    return ans%mod;
}
ll mi(ll a){
    return(fe(a,mod-2));
}

void fac(){
    fact[0]=1;
    infac[0]=1;
    forsn(i,1,2009){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        infac[i]=mi(fact[i]);
        infac[i]%=mod;
    }
}
ll ncr(ll a,ll b){
    if(a<b || a<=0)return 0;
    ll ans=fact[a];
    ans*=infac[b];
    ans%=mod;
    ans*=infac[a-b];
    ans%=mod;
    return ans;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

auto random_address = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

/* ---------------- start of code ---------------- */

void go() {
    int n;cin >> n;
    int a[n];
    forn(i,n)cin >> a[i];
    int cnt[4] =  {0};
    for(int i =n-1;i >= 0;i--) {

        cnt[a[i]]++;
        if(cnt[2] + (cnt[3] > 0) > cnt[1]) {
            cout << -1 << ln;
            return;
        }
    }
    queue<int> q;
    set<int> w;
    vector<pll> ans;
    int id = n+1;
    int idd[100005] = {0};
    for(int i = n-1; i >= 0;i--) {
        if(a[i] == 1) {
            q.push(i);
            idd[i] = --id;
            ans.pb({i+1, idd[i]});
            w.insert(i);
            continue;
        }
        if(a[i] == 2) {
            assert(!q.empty());
            ans.pb({i+1, idd[q.front()]});
            idd[i] = idd[q.front()];
            w.erase(q.front());
            q.pop();
            continue;
        }
        if(a[i] == 3) {
            assert(!w.empty());
            int p = *w.begin();
            idd[i] = --id;
            ans.pb({i+1, idd[i]});
            ans.pb({p+1, idd[i]});
            w.erase(p);
            w.insert(i);
        }
    }
    cout << ans.size() << ln;
    sort(all(ans));
    forn(i, ans.size()) {
        out2(ans[i].S, ans[i].F);
    }

}

int main(){
    fio;
    fflush(stdout);
    cout<<fixed<<setprecision(11);
    cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << endl
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO
using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
/* ---------------- constants ---------------- */
const ll MAXn=2e5 + 33,MAXlg=__lg(MAXn)+2;
const ll mod=1e9 + 7;
const ll INF=ll(1e15);
const ll PI = acosl(-1.0);

/* ---------------- utility functions ---------------- */
int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
int drr[] = {-2,-1,0,1,2};
int dcc[] = {-2,-1,0,1,2};
bool chk(int a, int b, int n, int m) {
    return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
    ll a = 1;
    while (m > 0){
        if (m&1) a = (a * n%md) % md;
        m /= 2;
        n = (n*n) % md;
    }
    return a % md;
}

ll expm(ll n, ll m){
    ll a = 1;
    while (m > 0){
        if(a < 0 or a >= (1e18 + n-1)/n) {
            return -1;
        }
        if (m&1) a = (a * n);
        m /= 2;
        n = (n*n);
    }
    return a;
}

void disp(vi v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
    if(x < 0)
        return -1;
    int l = sqrt(x);
    for (int i = -2; i <= 2; ++i)
        if (l + i >= 0 && (l + i) * (l + i) == x)
            return l;
    return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
    assert(n <= NPRR);
    lp.assign(n+1, 0);
    int i;
    for (i = 2;i <= n;++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            prr.push_back(i);
        }
        for (int u: prr) {
            if(i * u > n || u > lp[i]) break;
            lp[i * u] = u;
        }
    }
}
ll fact[300001],infac[300001];
ll fe(ll a,ll b){
    ll temp=a;
    ll ans=1ll;
    while(b){
        if(b&1){
            ans*=(ll)temp;
            ans%=mod;
        }
        b/=2ll;
        temp=temp*(ll)temp;
        temp%=mod;
    }
    ans += mod;
    ans %= mod;
    return ans%mod;
}
ll mi(ll a){
    return(fe(a,mod-2));
}

void fac(){
    fact[0]=1;
    infac[0]=1;
    forsn(i,1,2009){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        infac[i]=mi(fact[i]);
        infac[i]%=mod;
    }
}
ll ncr(ll a,ll b){
    if(a<b || a<=0)return 0;
    ll ans=fact[a];
    ans*=infac[b];
    ans%=mod;
    ans*=infac[a-b];
    ans%=mod;
    return ans;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

auto random_address = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

/* ---------------- start of code ---------------- */

void go() {
    int n;cin >> n;
    int a[n];
    forn(i,n)cin >> a[i];
    int cnt[4] =  {0};
//    for(int i =n-1;i >= 0;i--) {
//
//        cnt[a[i]]++;
//        if(cnt[2] > cnt[1]) {
//            cout << -1 << ln;
//            return;
//        }
//        if(cnt[3] > 0 and cnt[1] == 0 and cnt[2] == 0) {
//            cout << -1 << ln;
//            return;
//        }
//    }
    queue<int> q;
    set<int> w;
    vector<pll> ans;
    int id = n+1;
    int idd[100005] = {0};
    for(int i = n-1; i >= 0;i--) {
        if(a[i] == 1) {
            q.push(i);
            idd[i] = --id;
            ans.pb({i+1, idd[i]});
            w.insert(i);
            continue;
        }
        if(a[i] == 2) {
            if(q.empty()) {
                cout << -1 << ln;
                return;
            }
            assert(!q.empty());
            ans.pb({i+1, idd[q.front()]});
            idd[i] = idd[q.front()];
            w.erase(q.front());
            w.insert(i);
            q.pop();

            continue;
        }
        if(a[i] == 3) {
            if(w.empty()) {
                cout<<-1 << ln;
                return;
            }
            assert(!w.empty());
            int p = *w.begin();
            idd[i] = --id;
            ans.pb({i+1, idd[i]});
            ans.pb({p+1, idd[i]});
            w.erase(p);
            w.insert(i);
        }
    }
    cout << ans.size() << ln;
    sort(all(ans));
    forn(i, ans.size()) {
        out2(ans[i].S, ans[i].F);
    }

}

int main(){
    fio;
    fflush(stdout);
    cout<<fixed<<setprecision(11);
    cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */


#pragma GCC target ("sse4.2")
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define pb push_back
#define ln "\n"
#define forn(i,e) for(ll i=0; i<e; i++)
#define forsn(i,s,e) for(ll i=s; i<e; i++)
#define rforn(i,e) for(ll i=e; i>=0; i--)
#define rforsn(i,e,s) for(ll i=e; i>=s; i--)
#define vasort(v)         sort(v.begin(), v.end());
#define vdsort(v)         sort(v.begin(), v.end(),greater<ll>());
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)size(x))
#define     EB              emplace_back
#define     flush           fflush(stdout)
#define out1(x1) cout << x1 << ln
#define out2(x1,x2) cout << x1 << " " << x2 << endl
#define out3(x1,x2,x3) cout << x1 << " " << x2 << " " << x3 << endl
#define out4(x1,x2,x3,x4) cout << x1 << " " << x2 << " " << x3 << " " << x4 << ln
#define all(d) d.begin(), d.end()
#define unordered_set(T) unordered_set<T, custom_hash>
#define unordered_map(T1, T2) unordered_map<T1, T2, custom_hash>

#define in1(x1) cin >> x1
#define in2(x1,x2) cin >> x1 >> x2
#define in3(x1,x2,x3) cin >> x1 >> x2 >> x3
#define in4(x1,x2,x3,x4) cin >> x1 >> x2 >> x3 >> x4

#define arrin(a, n) forn(i, n) cin >> a[i];
#define arrout(a,n) forn(i,n) {cout << a[i] << " ";} cout << ln;

/* ---------------- IO ----------------*/

namespace IO
{
    const int BUFFER_SIZE = 1 << 15;
    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;
    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;
    char number_buffer[100];
    uint8_t lookup[100];
    void _update_input_buffer()
    {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;
        if (input_len == 0)
            input_buffer[0] = EOF;
    }
    inline char next_char(bool advance = true)
    {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    template <typename T>
    inline void read_int(T &number)
    {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do
        {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template <typename T, typename... Args>
    inline void read_int(T &number, Args &... args)
    {
        read_int(number);
        read_int(args...);
    }

    void _flush_output()
    {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c)
    {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template <typename T>
    inline void write_int(T number, char after = '\0')
    {
        if (number < 0)
        {
            write_char('-');
            number = -number;
        }
        int length = 0;
        while (number >= 10)
        {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }
        if (number != 0 || length == 0)
            write_char(number + '0');
        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);
        if (after)
            write_char(after);
    }
    void IOinit()
    {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);
        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
} // namespace IO
using namespace IO;

/* ---------------- typedefs ----------------*/
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
/* ---------------- constants ---------------- */
const ll MAXn=2e5 + 33,MAXlg=__lg(MAXn)+2;
const ll mod=1e9 + 7;
const ll INF=ll(1e15);
const ll PI = acosl(-1.0);

/* ---------------- utility functions ---------------- */
int dr[] = {0,1,-1,0,1,-1,1,-1};
int dc[] = {1,0,0,-1,1,-1,-1,1};
int drr[] = {-2,-1,0,1,2};
int dcc[] = {-2,-1,0,1,2};
bool chk(int a, int b, int n, int m) {
    return 0 <= a && a < n && 0 <= b && b < m;
}

ll exp(ll n, ll m, ll md){
    ll a = 1;
    while (m > 0){
        if (m&1) a = (a * n%md) % md;
        m /= 2;
        n = (n*n) % md;
    }
    return a % md;
}

ll expm(ll n, ll m){
    ll a = 1;
    while (m > 0){
        if(a < 0 or a >= (1e18 + n-1)/n) {
            return -1;
        }
        if (m&1) a = (a * n);
        m /= 2;
        n = (n*n);
    }
    return a;
}

void disp(vi v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<"\n";
}
void disp(vll v){
    for(auto u:v)
        cout<<u<<" ";
    cout<<endl;
}

int getSqr(int x){
    if(x < 0)
        return -1;
    int l = sqrt(x);
    for (int i = -2; i <= 2; ++i)
        if (l + i >= 0 && (l + i) * (l + i) == x)
            return l;
    return -1;
}

const int NPRR = 1e7;
vi lp;
vector<int> prr;
void prfac(int n = NPRR){
    assert(n <= NPRR);
    lp.assign(n+1, 0);
    int i;
    for (i = 2;i <= n;++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            prr.push_back(i);
        }
        for (int u: prr) {
            if(i * u > n || u > lp[i]) break;
            lp[i * u] = u;
        }
    }
}
ll fact[300001],infac[300001];
ll fe(ll a,ll b){
    ll temp=a;
    ll ans=1ll;
    while(b){
        if(b&1){
            ans*=(ll)temp;
            ans%=mod;
        }
        b/=2ll;
        temp=temp*(ll)temp;
        temp%=mod;
    }
    ans += mod;
    ans %= mod;
    return ans%mod;
}
ll mi(ll a){
    return(fe(a,mod-2));
}

void fac(){
    fact[0]=1;
    infac[0]=1;
    forsn(i,1,2009){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
        infac[i]=mi(fact[i]);
        infac[i]%=mod;
    }
}
ll ncr(ll a,ll b){
    if(a<b || a<=0)return 0;
    ll ans=fact[a];
    ans*=infac[b];
    ans%=mod;
    ans*=infac[a-b];
    ans%=mod;
    return ans;
}
/* custom hash for unordered map */
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

inline void read(int &x)
{
    scanf("%d", &x);
}

auto random_address = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

/* ---------------- start of code ---------------- */

void go() {
    int n;cin >> n;
    int a[n];
    forn(i,n)cin >> a[i];
    int cnt[4] =  {0};
    for(int i =n-1;i >= 0;i--) {

        cnt[a[i]]++;
        if(cnt[2] + (cnt[3] > 0) > cnt[1]) {
            cout << -1 << ln;
            return;
        }
    }
    queue<int> q;
    queue<int> w;
    vector<pll> ans;
    int id = 0;
    int ok[100005] = {-1};
    for(int i = n-1; i >= 0;i--) {
        if(a[i] == 1 ) {
            q.push(i);
            continue;
        }
        if(a[i] == 2){
            assert(!q.empty());
            ans.pb({i+1, ++id});
            ans.pb({q.front() + 1, id});
            ok[i] = id-1;
            ok[q.front()] =id-1;
            q.pop();
            continue;
        }
        if(a[i] == 3) {
            assert(!(q.empty() and w.empty()));
            if(!w.empty()) {
                ans.pb({i+1, ++id});
                ans.pb({w.front() +1, id});
                ok[i] = id-1;

            }else {
                ans.pb({q.front()+1, ++id});
                ans.pb({i+1, ++id});
                ans.pb({q.front()+1, id});
                ok[i] = id-1;
                ok[q.front()] = id-1;
                q.pop();
            }
            w.push(i);
        }
    }
    while(!q.empty()) {
        ans.pb({q.front()+1, ++id});
        q.pop();
    }
    cout << ans.size() << ln;
    forn(i, ans.size()) {
        out2(ans[i].S, ans[i].F);
    }

}

int main(){
    fio;
    fflush(stdout);
    cout<<fixed<<setprecision(11);
    cerr<<fixed<<setprecision(10);

    //freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

    ll tt = 1;

/*

    cin >> tt;
    ll t = tt;

    //*/

    auto start  = std::chrono::high_resolution_clock::now();

    while(tt--){
        //cout << "Case #" << t - tt << ": ";
        go();
    }
    auto stop = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
    //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s "<< endl;
    return 0;
}
/* ---------------- end of code ---------------- */


#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define ll long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
int a[1005],n,x;
void solve(){
	cin>>n>>x;
	int cnt=0;
	FOR(i,1,n){
		cin>>a[i];
		cnt+=a[i]&1;
	}
	if(!cnt){
		cout<<"No\n";
	}else if(cnt==n){
		if(x&1){
			cout<<"Yes\n";
		}else cout<<"No\n";
	}else if(x==n){
		if(cnt&1){
			cout<<"Yes\n";
		}else cout<<"No\n";
	}else cout<<"Yes\n";
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--)solve();
	RE 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,x,a[1003],T;
int main(){
	cin>>T;
	while(T--){
		cin>>n>>x;int cnt[2]={0,0};
		for(int i=0;i<n;i++)scanf("%d",a+i),cnt[a[i]%2]++;
		if((x%2==0&&cnt[0]==0)||cnt[1]==0)
			cout<<"No\n";
		else if(n>x||cnt[1]%2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<iostream>
#include<cstdio>

using namespace std;

inline int read(void)
{
    register int x=0,c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return x;
}

int main(void)
{
    int T=read();
    while(T--)
    {
        int n=read(),x=read(),q,odd=0,even=0;
        for(register int i=1;i<=n;++i)
        {
            q=read();
            if(q&1) ++odd;
            else ++even;
        }
        if(odd==0) puts("No");
        else
        {
            --odd;
            --x;
            if(even>=x) puts("Yes");
            else
            {
                int fir=even;
                int sec=odd>>1;
                if(x%2==0)
                {
                    int cnt=fir+sec*2;
                    if(cnt>=x) puts("Yes");
                    else puts("No");
                }
                else
                {
                    if(even==0) puts("No");
                    else
                    {
                        int cnt=sec*2;
                        if(cnt>=x) puts("Yes");
                        else
                        {
                            x-=cnt;
                            if(even>=x) puts("Yes");
                            else puts("No");
                        }
                    }
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int T;
    scanf("%d", &T);
    for(int i = 1; i <= T; i++)
    {
        int n,x;
        int a[999999];
        int os = 0, js = 0;
        bool b = 0;
        scanf("%d %d", &n, &x);
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
            if(a[i] % 2)
            {
                js++;
            }
            else
            {
                os++;
            }
        }
        if(js == 0)
        {
            cout << "No";
            continue;
        }
        int m = min(js % 2 == 1?js:js - 1,x % 2 == 1?x:x - 1);
        {
             if(x - i <= os)
             {
                 b = 1;
                 break;
             }
        }
        if(b)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    return 0;
}


#include<cstdio>
using namespace std;
template<class T>inline void read(T&a){
	char c=getchar();int f=1;a=0;
	while(c>'9'||c<'0'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0') a=(a<<1)+(a<<3)+c-48,c=getchar();
	a*=f;
}
template<class T>void write(T a){
	if(a<0) putchar('-'),a=-a;
	if(a>9) write(a/10);
	putchar(a%10+48);
}
int T,n,x,a,num[2];
int main(){
	read(T);while(T--){
		read(n);read(x);num[0]=num[1]=0;
		for(int i=1;i<=n;++i) read(a),++num[a&1];
		if((x==n&&num[1]%2==0)||(!num[0]&&x%2==0)||!num[1]) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,x,a[1003],T;
int main(){
	cin>>T;
	while(T--){
		cin>>n>>x;int cnt[2]={0,0};
		for(int i=0;i<n;i++)scanf("%d",a+i),cnt[a[i]%2]++;
		if(n>x||cnt[1]%2)
			cout<<"Yes\n";
		else
			cout<<"No\n";
	}
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
    int T;
    scanf("%d", &T);
    for(int i = 0; i < T; i++)
    {
        int n,x;
        int a[INT_MAX];
        int os = 0, js = 0;
        bool b = 0;
        scanf("%d %d", &n, &x);
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &a[i]);
            if(a[i] % 2)
            {
                js++;
            }
            else
            {
                os++;
            }
        }
        if(js == 0)
        {
            cout << "No";
            continue;
        }
        int m = min(js % 2 == 1?js:js - 1,x % 2 == 1?x:x - 1);
        {
             if(x - i <= os)
             {
                 b = 1;
                 break;
             }
        }
        if(b)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++;
            else ev++;
        }
        if (od == 0) {
            printf("No\n");
            continue;
        }
        if ((od - 1) / 2 * 2 + ev + 1 < x) {
            printf("No\n");
            continue;
        }
        if (1 + ev < x) {
            bool fail = false;
            if ((x - 1 - ev) & 1) {
                fail = true;
            }
            else fail = false;
            if (ev > 0) {
                if ((x - 1 - (ev - 1)) & 1) {
                    fail = true;
                }
                else fail = false;
            }
            if (fail) {
                printf("No\n");
                continue;
            }
        }
        printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++;
            else ev++;
        }
        if (od == 0) {
            printf("No\n");
            continue;
        }
        if ((od - 1) / 2 * 2 + ev + 1 < x) {
            printf("No\n");
            continue;
        }
        if (1 + ev < x) {
            if ((od - 1) / 2 * 2 + ev + 1 > x) {
                printf("No\n");
                continue;
            }
        }
        printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++; else ev++;
        }
        if (od == 0) {
            printf("NO\n");
            continue;
        }
        od--, x--;
        if (x & 1) {
            if (ev == 0) {
                printf("NO\n");
                continue;
            }
            x -= (ev & 1) ? ev : ev - 1;
            if (od / 2 * 2 >= x) printf("YES\n");
            else printf("NO\n");
        }
        else {
            if (ev == 0) {
                if (od / 2 * 2 >= x) printf("YES\n");
                else printf("NO\n");
                continue;
            }
            x -= (ev & 1) ? ev - 1 : ev;
            if (od / 2 * 2 >= x) printf("YES\n");
            else printf("NO\n");
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++;
            else ev++;
        }
        if (od == 0) {
            printf("No\n");
            continue;
        }
        if ((od - 1) / 2 * 2 + ev + 1 < x) {
            printf("No\n");
            continue;
        }
        if ((ev == 0) && ((od - 1) / 2 * 2 > x)) {
            printf("No\n");
            continue;
        }
        printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++;
            else ev++;
        }
        if (od == 0) {
            printf("No\n");
            continue;
        }
        if ((od - 1) / 2 * 2 + ev + 1 < x) {
            printf("No\n");
            continue;
        }
        if (1 + ev < x) {
            x -= 1 + ev;
            if (x & 1) {
                printf("No\n");
                continue;
            }
        }
        printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++;
            else ev++;
        }
        if (od == 0) {
            printf("No\n");
            continue;
        }
        if ((od - 1) / 2 * 2 + ev + 1 < x) {
            printf("No\n");
            continue;
        }
        if ((ev == 0) && ((od - 1) / 2 * 2 + 1 > x)) {
            printf("No\n");
            continue;
        }
        printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++;
            else ev++;
        }
        if (od == 0) {
            printf("No\n");
            continue;
        }
        if ((od - 1) / 2 * 2 + ev + 1 < x) {
            printf("No\n");
            continue;
        }
        printf("Yes\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int nmax = 2e5+5;

int main() {
    int TC;
    scanf("%d", &TC);
    for (int tc = 1; tc <= TC; tc++) {
        int n, x;
        scanf("%d%d", &n,&x);
        int od = 0, ev = 0;
        for (int i = 0; i < n; i++) {
            int a;
            scanf("%d", &a);
            if (a&1) od++; else ev++;
        }
        if (od == 0) {
            printf("NO\n");
            continue;
        }
        od--, x -= ev + 1;
        if (x <= 0) {
            printf("YES\n");
            continue;
        }
        printf("%s\n", (x & 1) ? "NO" : "YES");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0, even;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        even=n-odd;
        if(odd){
            if(even>=x-1)
                puts("Yes");
            else if(((x-even)&1)||((x-even+1)<=odd&&(x-even+1)%2)&&even)
                puts("Yes");
            else
				puts("No");
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&x);
            if(x&1)
                ++odd;
        }
        if(odd&1)
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        if(odd){
            if(n-odd>=x-1)
                puts("Yes");
            else if(((x-(n-odd))&1)||((x-(n-odd-1))&1)&&x<=n-1-!(odd&1))
                puts("Yes");
            else
				puts("No");
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0, even;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        even=n-odd;
        if(odd){
            if(even>=x-1)
                puts("Yes");
            else if(((x-even)&1)||(x-even+1)<=odd&&(x-even+1)%2)
                puts("Yes");
            else
				puts("No");
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&x);
            if(x&1)
                ++odd;
        }
        if((n-odd>=x-1&&odd)||((x-n+odd)&1))
            puts("Yes");
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        if(odd){
            if(n-odd>=x-1)
                puts("Yes");
            else if(((x-(n-odd))&1)||((x-(n-odd-1))&1)&&x!=n)
                puts("Yes");
            puts("No");
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        if(odd){
            if(x-1<=n-odd)
                puts("Yes");
            else{
                if((x-1-n+odd)&1)
                    puts("No");
                else
                    puts("Yes");
            }
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        if(odd){
            if(n-odd>=x-1)
                puts("Yes");
            else if(((x-(n-odd))&1)||((x-(n-odd-1))&1)&&x!=n)
                puts("Yes");
            else
				puts("No");
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x,p;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&p);
            if(p&1)
                ++odd;
        }
        if(odd){
            if(n-odd>=x-1)
                puts("Yes");
            else if(((x-(n-odd))&1)||(x-(n-odd-1))&1)
                puts("Yes");
            else
				puts("No");
        }
        else
            puts("No");
    }
    return 0;
}


#include<cstdio>
#include<algorithm>
using namespace std;

int t,n,x;
int main(){
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&x);
        int odd=0;
        for(int i=1;i<=n;++i){
            scanf("%d",&x);
            if(x&1)
                ++odd;
        }
        if(odd){
            if(x-1<=n-odd)
                puts("Yes");
            else{
                if((x-1-n+odd)&1)
                    puts("No");
                else
                    puts("Yes");
            }
        }
        else
            puts("No");
    }
    return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		int odd_pairs = odd.size() / 2;
		int evens = even.size();
		if(b&1&&evens) {evens--; b--;}
		// cout << odd_pairs << " " << evens;
		while(odd_pairs && b != 1) {
			odd_pairs--;
			b-=2;
		}
		while(evens) {
			evens--;
			b--;
		}
		// cout << b << " " << evens << " " <<  odd_pairs << endl;
		cout << (b <= 0 ? "Yes" : "No") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		int odd_pairs = odd.size() / 2;
		int evens = even.size();
		if(b&1&&evens) {evens--; b--;}
		// cout << odd_pairs << " " << evens;
		while(odd_pairs && b != 1) {
			odd_pairs--;
			b-=2;
		}
		while(evens) {
			evens--;
			b--;
		}
		cout << b << " " << evens << " " <<  odd_pairs << endl;
		cout << (b <= 0 ? "Yes" : "No") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	// cout << odd.size() << " " << even.size() << endl;
	if(odd.size() == 0) {
		cout << "No" << "\n";
		return;
	}
	odd.pop_back(); b--;
	while(b) {
		if(even.size()) {
			even.pop_back();
		}
		else if(!odd.size()&1) {
				odd.pop_back();
				odd.pop_back();
		}
		else {
			break;
		}
		b--;
	}
	cout << (b ? "No" : "Yes") << "\n";

}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		int odd_pairs = odd.size() / 2;
		int evens = even.size();
		if(b&1) {evens--; b--;}
		// cout << odd_pairs << " " << evens;
		while(odd_pairs) {
			odd_pairs--;
			b-=2;
		}
		while(evens) {
			evens--;
			b--;
		}
		cout << (b <= 0 ? "Yes" : "No") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		int odd_pairs = odd.size() / 2;
		int evens = even.size();
		if(b&1&&evens) {evens--; b--;}
		// cout << odd_pairs << " " << evens;
		while(odd_pairs) {
			odd_pairs--;
			b-=2;
		}
		while(evens) {
			evens--;
			b--;
		}
		cout << (b <= 0 ? "Yes" : "No") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q; if (q&1) odd.push_back(q); else even.push_back(q);
	};
	odd.pop_back(); b--;
	bool ok = true;
	while(b) {
		if(even.size() == 1 && b > 1) {
			if(odd.size() < 1) {
				ok = false;
				break;
			}
		}
		even.pop_back();
		b--
	}
	cout << (ok ? "Yes" : "No") << "\n";

}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		int odd_pairs = odd.size() / 2;
		int evens = even.size();
		cout << ((b - evens - (odd_pairs * 2) > 0) ? "No" : "Yes") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		int odd_pairs = odd.size() / 2;
		int evens = even.size();
		if(b - odd_pairs - evens <= 0) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
		// cout << (b ? "No" : "Yes") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q; if (q&1) odd.push_back(q); else even.push_back(q);
	};
	odd.pop_back(); b--;
	bool ok = true;
	while(b) {
		if(even.size() == 1 && b > 1) {
			if(odd.size() < 1) {
				ok = false;
				break;
			}
		}
		even.pop_back();
	}
	cout << (ok ? "Yes" : "No") << "\n";

}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

void solve() {
	int a, b; cin >> a >> b;
	vi odd;
	vi even;
	int q;
	F0R(i, a) {
		cin >> q;
		if (q&1) {
			odd.push_back(q);
		}
		else {
			even.push_back(q);
		}
	};
	if(!odd.size()) {
		cout << "No" << "\n";
	}
	else {
		odd.pop_back();
		// cout << b << endl;
		b=b-1;
		// cout << b << " " << odd.size() / 2 << " " << even.size() << "\n";
		// cout << (b - (int)(odd.size() / 2) - (int)even.size()) << endl;
		if((b - (int)(odd.size() / 2) - (int)even.size()) <= 0) {
			cout << "Yes" << "\n";
		}
		else {
			cout << "No" << "\n";
		}
		// cout << (b ? "No" : "Yes") << "\n";
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T;
	cin >> T;
	while(T--)
	solve();

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        int n,x,sum=0,i,p=0,flag=0;
        cin>>n>>x;
        int a[n+10];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            if(a[i]%2!=0)
            sum=a[i];
        }
        if(sum%2!=0){p++;flag=1;}
        if(p!=x)
        {
            for(i=0;i<n;i++)
            {
                if(a[i]%2==0&&flag==1)
                {
                    p++;
                }
            }
        }
        if(p>=x){cout<<"YES"<<"\n";}
        else{cout<<"NO"<<"\n";}
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        long long int n,x,sum=0,i,p=0,q=0,flag=0;
        cin>>n>>x;
        long long int a[n+10];
        for(i=0;i<n;i++)
        {
            cin>>a[i];
            if(a[i]%2!=0)
            {
                flag=1;
                q++;
            }
        }
        if(q%2==0){q--;}
        for(i=0;i<n&&q!=0;i++)
        {
            if(a[i]%2!=0)
            {
                sum+=a[i];
                q--;
                p++;
            }
        }
        if(p<x)
        {
            for(i=0;i<n;i++)
            {
                if(a[i]%2==0&&flag==1)
                {
                    p++;
                }
            }
        }
        if(p>=x){cout<<"YES"<<"\n";}
        else{cout<<"NO"<<"\n";}
    }
    return 0;
}