#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <time.h>

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define ll long long

const int N = 5*1e5+1;
const int M = 1e6+1;
const int inf = 1e9;
const int base = 1e9+7;

using namespace std;

int v1,v2,v3,v4;

int main()
{
    //ifstream cin ("input.txt");
    //ofstream cout ("output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> v1 >> v2 >> v3 >> v4;
    for (int i = 0; i <= 400; i++)
        for (int j = 0; j <= 400; j++)
            for (int o = 0; o <= 400; o++) if (i > j && j > o)
    {
        if (v1 > i || v2 > j || v3 > o || v4 > o) continue;
        if (2*v1 < i || 2*v2 < j || 2*v3 < o || 2*v4 < o)  continue;
        if (2*v4 >= i || 2*v4 >= j) continue;
        cout << i << "\n";
        cout << j << "\n";
        cout << o << "\n";
        return 0;
    }
    cout << -1;
}


#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <fstream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <time.h>

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define ll long long

const int N = 5*1e5+1;
const int M = 1e6+1;
const int inf = 1e9;
const int base = 1e9+7;

using namespace std;

int v1,v2,v3,v4;

int main()
{
    //ifstream cin ("input.txt");
    //ofstream cout ("output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> v1 >> v2 >> v3 >> v4;
    for (int i = 0; i <= 400; i++)
        for (int j = 0; j <= 400; j++)
            for (int o = 0; o <= 400; o++)
    {
        if (v1 > i || v2 > j || v3 > o || v4 > o) continue;
        if (2*v1 < i || 2*v2 < j || 2*v3 < o || 2*v4 < o)  continue;
        if (2*v4 >= i || 2*v4 >= j) continue;
        cout << i << "\n";
        cout << j << "\n";
        cout << o << "\n";
        return 0;
    }
    cout << -1;
}


// Made By Haireden Aibyn
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define fname ""
#define INF 2147483647
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
#define sc scanf
#define all(x) x.begin(), x.end()
#define size(x) int(x.size())
#define pr printf
#define deb(x) cerr << " | " << #x << " = " << x
#define pb push_back
#define ex exit(0)
#define y1 y4

typedef long long ll;
typedef unsigned long long ull;

const int N = 100500;

int main() {
    srand(time(NULL));
    #ifndef ONLINE_JUDGE
    freopen(fname".in", "r", stdin);
    freopen(fname".out", "w", stdout);
    #endif
    int v1,v2,v3,v4;
    cin >> v1 >> v2 >> v3 >> v4;
    if (v3 * 2 < v4) cout << -1, ex;
    if (v2 * 2 <= v4 * 2) cout << -1,ex;
    cout << v1 * 2 << "\n"<< v2 * 2  << "\n"<< v3 * 2;
    #ifndef ONLINE_JUDGE
       cerr << clock() << " ms";
    #endif
    return 0;
}


// Made By Haireden Aibyn
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define fname ""
#define INF 2147483647
#define MOD 1000000007
#define mp make_pair
#define F first
#define S second
#define sc scanf
#define all(x) x.begin(), x.end()
#define size(x) int(x.size())
#define pr printf
#define deb(x) cerr << " | " << #x << " = " << x
#define pb push_back
#define ex exit(0)
#define y1 y4

typedef long long ll;
typedef unsigned long long ull;

const int N = 100500;

int main() {
    srand(time(NULL));
    #ifndef ONLINE_JUDGE
    freopen(fname".in", "r", stdin);
    freopen(fname".out", "w", stdout);
    #endif
    int v1,v2,v3,v4;
    cin >> v1 >> v2 >> v3 >> v4;
    if (v3 * 2 < v4 || v4 * 2 < v3) cout << -1, ex;
    if (v2 * 2 <= v4 * 2) cout << -1,ex;
    cout << v1 * 2 << "\n"<< v2 * 2  << "\n"<< min(v3 * 2, v4 * 2);
    #ifndef ONLINE_JUDGE
       cerr << clock() << " ms";
    #endif
    return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 200; x++)
	{
		if (vpapa <= x && 2 * vpapa >= x)
		{
			v1 = x;
		}
	}
	for (int y = 0; y <= 200; y++)
	{

		if (vmama <= y && 2 * vmama >= y && v1 > y)
		{
			v2 = y;
		}
	}
	for (int z = 0; z <= 200; z++)
	{
		if (vsin <= z && 2 * vsin >= z && v2 > z)
		{
			v3 = z;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0 && 2 * vmasha >= v3 && vmasha <= v3)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 200; x++)
	{
		if (vpapa <= x && 2 * vpapa >= x)
		{
			v1 = x;
		}
	}
	for (int y = 0; y <= 200; y++)
	{

		if (vmama <= y && 2 * vmama >= y && v1 > y)
		{
			v2 = y;
		}
	}
	for (int z = 0; z <= 200; z++)
	{
		if (vsin <= z && 2 * vsin >= z && v2 > z)
		{
			v3 = z;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0 && 2 * vmasha >= v3 && vmasha <= v3 && 2 * vmasha < v2)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 200; x++)
	{
		if (vpapa <= x && 2 * vpapa >= x)
		{
			v1 = x;
		}
	}
	for (int y = 0; y <= 200; y++)
	{

		if (vmama <= y && 2 * vmama >= y && v1 > y && 2 * vmasha < y)
		{
			v2 = y;
		}
	}
	for (int z = 0; z <= 200; z++)
	{
		if (vsin <= z && 2 * vsin >= z && v2 > z && 2 * vmasha >= z && vmasha <= z)
		{
			v3 = z;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa<=x && 2 * vpapa>=x && vmasha <= x)
		{
			v1 = x;
		}
	}
	for (int y = 0; y <= 100; y++)
	{

		if (vmama <= y && 2 * vmama >= y && vmasha <= y)
		{
			v2 = y;
		}
	}
	for (int z = 0; z <= 100; z++)
	{
		if (vsin <= z && 2 * vsin >= z && vmasha <= z)
		{
			v3 = z;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0 && v3<v2<v1 && 2 * vmasha >= v3)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa<=x && 2 * vpapa>=x && vmasha <= x)
		{
			v1 = x;
		}
	}
	for (int y = 0; y <= 100; y++)
	{

		if (vmama <= y && 2 * vmama >= y && vmasha <= y)
		{
			v2 = y;
		}
	}
	for (int z = 0; z <= 100; z++)
	{
		if (vsin <= z && 2 * vsin >= z && vmasha <= z)
		{
			v3 = z;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0 && v3<v2<v1)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa <= x && 2 * vpapa >= x && vmasha <= x)
		{
			v1 = x;
			break;
		}
	}
	for (int y = 0; y <= 100; y++)
	{

		if (vmama <= y && 2 * vmama >= y && vmasha <= y)
		{
			v2 = y;
			break;
		}
	}
	for (int z = 0; z <= 100; z++)
	{
		if (vsin <= z && 2 * vsin >= z && vmasha <= z)
		{
			v3 = z;
			break;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0 && 2 * vmasha >= v3)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa <= x && 2 * vpapa >= x)
		{
			v1 = x;
		}
	}
	for (int y = 0; y <= 100; y++)
	{

		if (vmama <= y && 2 * vmama >= y && v1 > y)
		{
			v2 = y;
		}
	}
	for (int z = 0; z <= 100; z++)
	{
		if (vsin <= z && 2 * vsin >= z && v2 > z)
		{
			v3 = z;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0 && 2 * vmasha >= v3 && vmasha <= v3)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa<=x && 2 * vpapa>=x && vmasha <= x)
		{
			v1 = x;
		}
		if (vmama<=x && 2 * vmama>=x && vmasha <= x)
		{
			v2 = x;
		}
		if (vsin<=x && 2 * vsin>=x && vmasha <= x)
		{
			v3 = x;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0)
	{
		cout << v1 << endl;
		cout << v2 << endl;
		cout << v3 << endl;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


// ConsoleApplication125.cpp: РѕРїСЂРµРґРµР»СЏРµС‚ С‚РѕС‡РєСѓ РІС…РѕРґР° РґР»СЏ РєРѕРЅСЃРѕР»СЊРЅРѕРіРѕ РїСЂРёР»РѕР¶РµРЅРёСЏ.
//
#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa<=x && 2 * vpapa>=x && vmasha <= vsin)
		{
			v1 = x;
		}
		if (vmama<=x && 2 * vmama>=x && vmasha <= vsin)
		{
			v2 = x;
		}
		if (vsin<=x && 2 * vsin>=x && vmasha <= vsin)
		{
			v3 = x;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0)
	{
		cout << v1 << " " << v2 << " " << v3;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


#include <iostream>
using namespace std;

int main()
{
	int v1 = 0, v2 = 0, v3 = 0, vpapa, vmama, vsin, vmasha;
	cin >> vpapa >> vmama >> vsin >> vmasha;
	for (int x = 0; x <= 100; x++)
	{
		if (vpapa<=x && 2 * vpapa>=x && vmasha <= x)
		{
			v1 = x;
		}
		if (vmama<=x && 2 * vmama>=x && vmasha <= x)
		{
			v2 = x;
		}
		if (vsin<=x && 2 * vsin>=x && vmasha <= x)
		{
			v3 = x;
		}
	}
	if (v1 != 0 && v2 != 0 && v3 != 0)
	{
		cout << v1 << " " << v2 << " " << v3;
	}
	else
	{
		cout << "-1";
	}
	return 0;
}


#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;
    int a1 = 2 * v1, a2 = 2 * v2, a3;
    if (vm > a1 || (2 * vm >= a1 && vm <= a1))
    {
        cout << -1;
        return 0;
    }
    if (vm > a2 || (2 * vm >= a2 && vm <= a2))
    {
        cout << -1;
        return 0;
    }
    if (vm > 2 * v3 || (vm * 2 < v3))
    {
        cout << -1;
        return 0;
    }
    else
        a3 = max(vm, v3);

    cout << a1 << ' ' << a2 << ' ' << a3;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include<queue>
#include <cstring>
#include <string>
using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int x1=1;x1<=201;x1++){
        if (x1 >= a && x1<=2*a && x1>2*d && d<=x1 ){
            for(int x2=1;x2<x1;x2++){
                if (x2 >= b && x2<=2*b && x2>2*d && d<=x2){
                    for(int x3=1;x3<x2;x3++){
                        if (x3 >= c && x3<=2*c && x3<=2*d && d<=x3 ){
                            cout<<x1<<" "<<x2<<" "<<x3;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<-1;
    return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include<queue>
#include <cstring>
#include <string>
using namespace std;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    for(int x1=1;x1<=201;x1++){
        if (x1 >= a && x1<=2*a && x1>2*d && d<=x1 ){
            for(int x2=1;x2<=201;x2++){
                if (x2 >= b && x2<=2*b && x2>2*d && d<=x2){
                    for(int x3=1;x3<=201;x3++){
                        if (x3 >= c && x3<=2*c && x3<=2*d && d<=x3 ){
                            cout<<x1<<" "<<x2<<" "<<x3;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<-1;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long mas[1000100];

int main()
{
    int v1,v2,v3,v4;
    cin >> v1 >> v2 >> v3 >> v4;
    if (v4 >= v2){
        cout << -1;
        return 0;
    }
    int a1,a2,a3;
    a1 = v1;
    a2 = v2 ;
    a3 = max(v3, v4);
    if (v3 * 2 < a3 || v4 * 2 < a3  ){
        cout << -1; return 0;
    }
    cout << a1 << " " << a2  << " " << a3;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long mas[1000100];

int main()
{
    int v1,v2,v3,v4;
    cin >> v1 >> v2 >> v3 >> v4;
    int a1,a2,a3;
    a1 = v1;
    a2 = v2 ;
    a3 = max(v3, v4);
    if (v3 * 2 <= a3 || v4 * 2 <= a3 ){
        cout << -1; return 0;
    }
    cout << a1 << " " << a2  << " " << a3;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long mas[1000100];

int main()
{
    int v1,v2,v3,v4;
    cin >> v1 >> v2 >> v3 >> v4;
    int a1,a2,a3;
    a1 = v1;
    a2 = v2 ;
    a3 = max(v3, v4);
    if (v3 * 2 < a3 || v4 * 2 < a3 ){
        cout << -1; return 0;
    }
    cout << a1 << " " << a2  << " " << a3;
    return 0;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  for(int i = a[3]; i <= a[3] * 2; i++){
    for(int j = a[2]; j <= a[2] * 2; j++){
      for(int k = a[1]; k <= a[1] * 2; k++){
        if(i < j && j < k){
          if(a[4] <= i && a[4] * 2 < j && a[4] * 2 < k){
            if(a[4] * 2 >= i){
              cout << a[1] << '\n' << a[2] << '\n' << a[3] << '\n';
              return 0;
            }
          }
        }
      }
    }
  }
  cout << -1;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  for(int i = a[3]; i <= a[3] * 2; i++){
    for(int j = a[2]; j <= a[2] * 2; j++){
      for(int k = a[1]; k <= a[1] * 2; k++){
        if(i < j && j < k){
          if(a[4] <= i && a[4] * 2 < j && a[4] * 2 < k){
            if(a[4] * 2 >= i){
              cout << k << '\n' << j << '\n' << i << '\n';
              return 0;
            }
          }
        }
      }
    }
  }
  cout << -1;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  b[1] = a[1], b[2] = a[2], b[3] = a[3];
  sort(a + 1, a + 1 + 3);
  reverse(a + 1, a + 1 + 3);
  if(b[1] == a[1] && a[2] == b[2] && a[3] == b[3]){
    if(a[3] * 2 >= a[4]){
      if(a[3] * 2 <= a[4] * 2){
        cout << a[1] << "\n" << a[2] << "\n" << a[3] << "\n";
        return 0;
      }
    }
  }
  cout << -1;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  for(int i = a[3]; i <= a[3] * 2; i++){
    for(int j = a[2]; j <= a[2] * 2; j++){
      for(int k = a[1]; k <= a[1] * 2; k++){
        if(i < j && j < k){
          if(a[4] <= i){
            if(a[4] * 2 >= i){
              cout << a[1] << '\n' << a[2] << '\n' << a[3] << '\n';
              return 0;
            }
          }
        }
      }
    }
  }
  cout << -1;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  b[1] = a[1], b[2] = a[2], b[3] = a[3];
  sort(a + 1, a + 3);
  reverse(a + 1, a + 3);
  if(b[1] == a[1] && a[2] == b[2] && a[3] == b[3]){
    if(a[3] * 2 >= a[4]){
      if(a[3] * 2 <= a[4] * 2){
        cout << a[1] << "\n" << a[2] << "\n" << a[3] << "\n";
        return 0;
      }
    }
  }
  cout << -1;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  if(a[4] <= a[3] * 2){
    if(a[4] * 2 >= a[3] * 2){
      cout << a[1] * 2 << "\n" << a[2] * 2 << "\n" << a[3] * 2 << '\n';
    }
  }
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  if(a[4] <= a[3] * 2){
    if(a[4] * 2 >= a[3] * 2){
      cout << a[1] * 2 << "\n" << a[2] * 2 << "\n" << a[3] * 2 << '\n';
      return 0;
    }
  }
  cout << -1;
}


/*
    Rem is cute :D
*/

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

using namespace std;

#define pii pair<int, int>
#define pll pair<ll, ll>

#define pb push_back
#define eb emplace_back
#define mp make_pair

#define fi first
#define se second

#define y0 asjdlksajldjals
#define y1 ajsldjalksdkjlk

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int inf = (int)1e9 + 7;
const int maxn = (int)4e5 + 7;
const int lmaxn = (int)6e5 + 7;
const ll linf = (ll)1e16 + 7;

const ld eps = ld(1e-11);

const ll dx[] = {-1, 0, 0, 1};
const ll dy[] = {0, -1, 1, 0};

ll gcd(ll a, ll b){
    while(b) a %= b, swap(a, b);
    return a | b;
}

ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}
int a[11], b[11];
int main(){
  cin >> a[1] >> a[2] >> a[3] >> a[4];
  for(int i = a[3]; i <= a[3] * 2; i++){
    for(int j = a[2]; j <= a[2] * 2; j++){
      for(int k = a[1]; k <= a[1] * 2; k++){
        if(i < j && j < k){
          if(a[4] <= i && a[4] * 2 < j && a[4] * 2 < k){
            if(a[4] * 2 >= i){
              cout << i << '\n' << j << '\n' << k << '\n';
              return 0;
            }
          }
        }
      }
    }
  }
  cout << -1;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <math.h>
#include <string>
#include <ctime>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    int m1, m2, m3, m;
    cin >> m1 >> m2 >> m3 >> m;
    for (int v3 = 1; v3 <= 300; ++v3) {
        for (int v2 = v3 + 1; v2 <= 300; ++v2) {
            for (int v1 = v2 + 1; v1 <= 300; ++v1) {
                if (m1 <= v1 && 2 * m1 >= v1 && m2 <= v2 && 2 * m2 >= v2 && m3 <= v3 && 2 * m3 >= v3 && m <= v3 && 2 * m >= v3 && 2 * m < v2 && 2 * m < v1) {
                    cout << v1 << endl << v2 << endl << v3 << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <math.h>
#include <string>
#include <ctime>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> c >> b >> a >> d;
    int mi1, mi2, mi3;
    int ma1, ma2, ma3;
    mi1 = max(a, d);
    ma1 = min(2 * d, 2 * a);
    mi2 = max(b, 2 * d + 1);
    ma2 = 2 * b;
    mi3 = max(c, 2 * d + 1);
    ma3 = 2 * c;
    if (mi1 > ma1 || mi2 > ma2 || mi3 > ma3) {
        cout << -1;
    } else {
        cout << mi3 << endl << mi2 << endl << mi1 << endl;
    }
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <math.h>
#include <string>
#include <ctime>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> c >> b >> a >> d;
    int mi1, mi2, mi3;
    int ma1, ma2, ma3;
    mi1 = max(a, d);
    ma1 = min(2 * d, 2 * a);
    mi2 = max(b, 2 * d + 1);
    ma2 = 2 * b;
    mi3 = max(c, 2 * d + 1);
    ma3 = 2 * c;
    int ans1 = mi1, ans2 = max(mi2, ans1 + 1), ans3 = max(mi3, ans2 + 1);
    if (ans1 > ma1 || ans2 > ma2 || ans3 > ma3) {
        cout << -1;
    } else {
        cout << mi3 << endl << mi2 << endl << mi1 << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (d * 2 >= a * 2 || d * 2 >= b * 2 || d * 2 < max(c, d) || c * 2 < max(c, d)) {
        cout << -1;
        return 0;
    }
    cout << a * 2 << " " << b * 2 << " " << max(c, d);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pl;
typedef pair <ld, ld> pd;

#define x first
#define y second
#define pb push_back

const ll INF = 1e18 + 7;
const ll M = 510;
const ll N = 1e6 + 100;
const ll dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
const ll dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll v1, v2, v3, v4;
    cin >> v1 >> v2 >> v3 >> v4;
    ll a = v1 * 2;
    ll b = v2 * 2;

    for (ll i = 1; i <= (ll)1e4; i++)
    {
        if (i > a / 2 || i > b / 2)
        {
            cout << -1;
            return 0;
        }
        if (i * 2 >= v4 && v4 <= i && v3 * 2 >= i && v3 <= i)
        {
            cout << a << endl;
            cout << b << endl;
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pl;
typedef pair <ld, ld> pd;

#define x first
#define y second
#define pb push_back

const ll INF = 1e18 + 7;
const ll M = 510;
const ll N = 1e6 + 100;
const ll dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
const ll dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll v1, v2, v3, m;
    cin >> v1 >> v2 >> v3 >> m;

    ll a = max(v3, m), b = min(v3, m);
    if (a > b * 2 || m >= v2)
        return cout << -1, 0;

    ll ans = min(v3, m) * 2;
    cout << v1 * 2 << endl << v2 * 2 << endl << ans << endl;
    return 0;
}


#include <iostream>
#include <vector>

using namespace std;

const int maxn = 100000;
int a,b,c, m;
int car_1 = 0, car_2 = 0, car_3 = 0;
int main(){
    cin >> a >> b >> c >> m;
    int car_1, car_2, car_3;
    for(int i = c; i <= 2 * c; ++i){
        if(i >=m &&  i <=2*m){
            car_3 = i;
            break;
        }
        else car_3 = 0;
    }
    for(int i = b; i <= 2 * b; ++i){
        if(i >= car_3 && i > 2 * m){
            car_2 = i;
            break;
        }
        else car_2 = 0;
    }
    for(int i =a; i <= 2 * a; ++i){
        if(i > 2 *  m && i > car_2){
            car_1 = i;
            break;
        }
        else car_1 = 0;
    }
    if(car_1&& car_2 && car_3)
        cout << car_1 << '\n' << car_2 << '\n' << car_3 << '\n';
    else
        cout << "-1\n";
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define vvint vector< vector<int> >
#define mp(a,b) make_pair(a,b)
using namespace std;

int main()
{
    int b1,b2,b3,m;
    cin>>b1>>b2>>b3>>m;
    b1*=2;
    b2*=2;
    if(m<b3 && m*2>=b3)
        b3=m*2;
    else
    if(m>=b3 && m<=b3*2)
        b3*=2;
        else
        {
            cout<<"-1";
           // system("pause");
            return 0;
        }
    cout<<b1<<'\n'<<b2<<'\n'<<b3;
    //system("pause");
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define vvint vector< vector<int> >
#define mp(a,b) make_pair(a,b)
using namespace std;

int main()
{
    int b1,b2,b3,m,ans;
    cin>>b1>>b2>>b3>>m;
    b1*=2;
    b2*=2;
    if(m<b3 && m*2>=b3)
        ans=b3;
    else
    if(m>=b3 && m<=b3*2)
        ans=b3;
        else
        {
            cout<<"-1";
          //  system("pause");
            return 0;
        }
    if(b1>b2 && b2>ans)
    cout<<b1<<'\n'<<b2<<'\n'<<ans;
    else
        cout<<"-1";
   // system("pause");
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define vvint vector< vector<int> >
#define mp(a,b) make_pair(a,b)
using namespace std;

int main()
{
    int b1,b2,b3,m,ans;
    cin>>b1>>b2>>b3>>m;
    b1*=2;
    b2*=2;
    if(m<b3 && m*2>=b3)
        ans=b3;
    else
    if(m>=b3 && m<=b3*2)
        ans=m;
        else
        {
            cout<<"-1";
          //  system("pause");
            return 0;
        }
    if(b1>b2 && b2>ans)
    cout<<b1<<'\n'<<b2<<'\n'<<ans;
    else
        cout<<"-1";
   // system("pause");
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define vint vector<int>
#define vvint vector< vector<int> >
#define mp(a,b) make_pair(a,b)
using namespace std;

int main()
{
    int b1,b2,b3,m,ans;
    cin>>b1>>b2>>b3>>m;
    b1*=2;
    b2*=2;
    if(m<b3 && m*2>=b3)
        ans=b3;
    else
    if(m>=b3 && m<=b3*2)
        ans=m;
        else
        {
            cout<<"-1";
          //  system("pause");
            return 0;
        }
    if(b1>b2 && b2>ans && b1>m*2 && b2>m*2)
    cout<<b1<<'\n'<<b2<<'\n'<<ans;
    else
        cout<<"-1";
   // system("pause");
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;
    for (int b3 = max(v3, vm); 2 * vm >= b3 && 2 * v3 >= b3; b3++) {
        for (int b2 = max(b3 + 1, max(2 * vm + 1, v2)); b2 <= 2 * v2; b2++) {
            for (int b1 = max(b2 + 1, max(2 * vm + 1, v1)); b1 <= 2 * v1; b1++) {
                cout << b1 << endl << b2 << endl << b3;
                return 0;
            }
    }
    }
    cout << -1;

    return 0;
}


#include <iostream>

using namespace std;

int main() {
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;
    for (int i = 0; i < 201; ++i){
        for (int j = 0; j < 201; ++j){
            for (int k = 0; k < 201; ++k){
                if ((i > j) and (j > k) and (v1 <= i) and (v2 <= j) and (v3 <= k) and (vm <= k) and (2 * v1 >= i) and (2 * v2 >= j) and (2 * v3 >= k) and (2 * vm >= k) and (2 * vm < i) and (2 * vm < j)){
                    cout << i << ' ' << j << ' ' << k;
                    exit(0);
                }
            }
        }
    }
    cout << -1;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
// fflush(stdout);
int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    a *= 2;
    b *= 2;
    for (long long i = c; i < b; i++)
    {
        if (i >= d && d * 2 >= i)
        {
            cout << a << endl << b << endl << i << endl;
            return 0;
        }
    }
    cout << "-1";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e9 + 7;
// fflush(stdout);
int main()
{
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    a *= 2;
    b *= 2;
    for (long long i = c; i < b; i++)
    {
        if (i >= d && d * 2 >= i && c <= i && c * 2 >= i)
        {
            cout << a << endl << b << endl << i << endl;
            return 0;
        }
    }
    cout << "-1";
    return 0;
}


    #include <bits/stdc++.h>
    using namespace std;
    const long long Mod = 1e9 + 7;
    // fflush(stdout);
    int main()
    {
        long long a, b, c, d;
        cin >> a >> b >> c >> d;
        a *= 2;
        b *= 2;
        if (d * 2 >= a || d * 2 >= b)
        {
            cout << "-1";
            return 0;
        }
        for (long long i = c; i < b; i++)
        {
            if (i >= d && d * 2 >= i && c <= i && c * 2 >= i && i != b && i <= a && i <= b)
            {
                cout << a << endl << b << endl << i << endl;
                return 0;
            }
        }
        cout << "-1";
        return 0;
    }


#include<bits/stdc++.h>

using namespace std;

int main()
{
    int m, m1, m2, m3;
    cin >> m3 >> m2 >> m1 >> m;
    for (int a = m3; a <= 2 * m3; ++a)
    {
        for (int b = m2; b <= 2 * m2; ++b)
        {
            for (int c = m1; c <= 2 * m1; ++c)
            {
                if (m <= a && m <= b && m <= c && 2 * m < a && 2 * m < b && 2 * m >= c && a > b && b > c)
                {
                    cout << a << endl;
                    cout << b << endl;
                    cout << c << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << endl;
}


#include <iostream>

using namespace std;

int main(){
	int v[3];
	int vm;

	for (int i = 0; i < 3; i++)
		cin >> v[i];

	cin >> vm;

	if (2 * vm >= v[2] && 2 * vm < v[1] && v[2] >= vm)
		cout << v[0] << "\n" << v[1] << "\n" << v[2];
	else
		cout << "-1";

	return 0;
}


#include <iostream>

using namespace std;

int main(){
	int v[3];
	int vm;

	for (int i = 0; i < 3; i++)
		cin >> v[i];

	cin >> vm;

	if (2 * vm >= v[2] && 2 * vm < v[1] && v[2] > vm)
		cout << v[0] << " " << v[1] << " " << v[2];
	else
		cout << "-1";

	return 0;
}


#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define die(x) {cout << x; return 0;}

using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
const lint inf = 1000000007;

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;

    if (v2 <= vm || 2*v3 < vm || v3 > 2*vm) die(-1);

    cout << 2*v1 << '\n' << 2*v2 << '\n' << 2*v3;

    return 0;
}


#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define die(x) {cout << x; return 0;}

using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
const lint inf = 1000000007;

int main() {
    cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;

    if (v2 <= vm || 2*v3 < vm || v3 > 2*vm) die(-1);
    int v;
    if (vm <= v3) v = v3;
    else v = vm;

    cout << 2*v1 << '\n' << 2*v2 << '\n' << v;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 111111;
const int INF = 1e9;

void solution() {
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;

    for (int i = v1; i <= v1 * 2; i++)
        for (int j = v2; j <= v2 * 2; j++)
            for (int k = v3; k <= v3 * 2; k++) {
            if (i >= j && j >= k && k >= vm) {
                cout << i << endl << j << endl << k;
                return;
            }
            }

    cout << -1;
}

int main()
{
 //   freopen("input.txt", "r", stdin);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 111111;
const int INF = 1e9;

void solution() {
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;

    for (int i = v1; i <= v1 * 2; i++)
        for (int j = v2; j <= v2 * 2; j++)
            for (int k = v3; k <= v3 * 2; k++) {
            if (i > j && j > k && k >= vm) {
                cout << i << endl << j << endl << k;
                return;
            }
            }

    cout << -1;
}

int main()
{
 //   freopen("input.txt", "r", stdin);
    solution();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 111111;
const int INF = 1e9;

void solution() {
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;

    for (int i = v1; i <= v1 * 2; i++)
        for (int j = v2; j <= v2 * 2; j++)
            for (int k = v3; k <= v3 * 2; k++) {
            if (i > j && j > k &&
               i > vm*2 && j > vm*2
               && k >= vm && k <= vm*2

               ) {
                cout << i << endl << j << endl << k;
                return;
            }
            }

    cout << -1;
}

int main()
{
 //   freopen("input.txt", "r", stdin);
    solution();
    return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>

#define MAX(a, b) (((a) > (b)) ? (a): (b))
#define MIN(a, b) (((a) < (b)) ? (a): (b))
#define ll long long
#define forn(i, j, n) for(ll i = j; i < n; ++i)
#define forc(i, n, j) for(ll i = n-1; i >= j; --i)
#define forr(i, j, n, d) for(ll i = j; i != n; d)
#define m_p make_pair
#define ft first
#define sd second

using namespace std;

int main()
{
	long a, b, c, m;
	cin >> a >> b >> c >> m;
	bool fl = false;
	if (2 * c < m) fl = true;
	if (2 * m < c) fl = true;

	if(m >= b) fl = true;
	if (m >= a) fl = true;

	if (fl) {
		cout << -1 << endl;
	}
	else {
		cout << MAX(a, m * 2 + 2) << ' ';
		cout << MAX(b, m * 2 + 1) << ' ';
		cout << MAX(c, m) << endl;
	}

	cin >> a;
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<cmath>
#include<map>

using namespace std;

int main()
{
	int v1, v2, v3, vm;
	scanf("%d %d %d %d", &v1, &v2, &v3, &vm);
	int a, b, c;
	for (a = v3; a <= 2 * v3; ++a)
	{
		for (b = max(v2, a + 1); b <= 2 * v2; ++b)
		{
			for (c = max(v1, b + 1); c <= 2 * v1; ++c)
			{
				if (vm <= a && vm <= b && vm <= c && a <= 2 * vm && b > 2 * vm && c > 2 * vm)
				{
					printf("%d %d %d\n", c, b, a);
					//system("pause");
					return 0;
				}
			}
		}
	}
	printf("-1\n");
	//system("pause");
	return 0;
}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;
    int i;
    for (i = 2 * v1; i >= v1; i--)
    {
        if (2 * vm < i || vm > i)
            break;
    }
    if (i == v1 - 1)
    {
        cout << -1;
        return 0;
    }
    v1 = i;

    for (i = 2 * v2; i >= v2; i--)
    {
        if ((2 * vm < i || vm > i) && i < v1)
            break;
    }
    if (i == v2 - 1)
    {
        cout << -1;
        return 0;
    }
    v2 = i;

    for (i = 2 * v3; i >= v3; i--)
    {
        if ((2 * vm >= i && vm <= i) && i < v2)
            break;
    }
    if (i == v3 - 1)
    {
        cout << -1;
        return 0;
    }
    cout << v1 << "\n" << v2 << "\n" << v3;
    return 0;
}


#include <iostream>
#include <vector>
#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;
    int i;
    for (i = 2 * v1; i >= v1; i--)
    {
        if (2 * vm < i && vm <= i)
            break;
    }
    if (i == v1 - 1)
    {
        cout << -1;
        return 0;
    }
    v1 = i;

    for (i = 2 * v2; i >= v2; i--)
    {
        if (2 * vm < i && vm < i && i < v1)
            break;
    }
    if (i == v2 - 1)
    {
        cout << -1;
        return 0;
    }
    v2 = i;

    for (i = 2 * v3; i >= v3; i--)
    {
        if (2 * vm >= i && vm <= i && i < v2)
            break;
    }
    if (i == v3 - 1)
    {
        cout << -1;
        return 0;
    }
    v3 = i;
    cout << v1 << "\n" << v2 << "\n" << v3;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int linf = 1e9 + 7;
const int N = 5e5;

int a, b, c, d;

int main(){
	scanf("%d%d%d%d", &a, &b, &c, &d);
	if(max(d, c) > (d * 2) || max(d, c) > (c * 2) || (d * 2) >= (a * 2) || (d * 2) >= (b * 2)){
    printf("-1");
    return 0;
	}
	else
		cout << a * 2 << "\n" << b * 2 << "\n" << max(d, c) << "\n";
}


#include <bits/stdc++.h>

using namespace std;

int main(){
	int v1, v2, v3, vm;
	scanf("%d%d%d%d", &v1, &v2, &v3, &vm);
	if(vm > v3)
    cout << -1 << "\n";
	else
		cout << v1 << "\n" << v2 << "\n" << v3 << "\n";
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    int v1, v2, v3, vm;
    cin >> v1 >> v2 >> v3 >> vm;
    for (int i = v1; i <= 2 * v1; ++i) {
        for (int j = v2; j <= 2 * v2; ++j) {
            for (int k = v3; k <= 2 * v3; ++k) {
                if (i > j && j > k && vm <= k && 2 * vm < i && 2 * vm < j && 2 * vm >= k) {
                    cout << i << endl << j << endl << k << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1;
    return 0;
}


#include <iostream>
using namespace std;

int main() {
	long long v1 = 0, v2 = 0, v3 = 0, a = 0;
	long long minv1 = 0, minv2 = 0, minv3 = 0, maxv1 = 0, maxv2 = 0, maxv3 = 0;
	long long mina = 0, maxa = 0;
	cin >> v1 >> v2 >> v3 >> a;
	maxv1 = 2*v1;
	minv1 = v1;
	maxv2 = 2*v2;
	minv2 = v2;
	maxv3 = 2*v3;
	minv3 = v3;
	maxa = 2*a;
	mina = a;
	if ((mina < maxv3)&&(mina < maxv2)&&(mina < maxv1)&&(maxa < maxv2)&&(maxa >= maxv3))
	{
		cout << maxv1 << endl;
		cout << maxv2 << endl;
		cout << maxv3 << endl;
	}
	else cout << -1;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	long long v1 = 0, v2 = 0, v3 = 0, a = 0;
	long long minv1 = 0, minv2 = 0, minv3 = 0, maxv1 = 0, maxv2 = 0, maxv3 = 0;
	long long mina = 0, maxa = 0;
	cin >> v1 >> v2 >> v3 >> a;
	maxv1 = 2*v1;
	minv1 = v1;
	maxv2 = 2*v2;
	minv2 = v2;
	maxv3 = 2*v3;
	minv3 = v3;
	maxa = 2*a;
	mina = a;
	if ((mina <= maxv3)&&(maxa >= maxv3)&&(maxa < maxv2))
	{
		cout << maxv1 << endl;
		cout << maxv2 << endl;
		cout << maxv3 << endl;
	}
	else if ((mina <= minv3)&&(maxa >= minv3)&&(maxa < maxv2))
	{
		cout << maxv1 << endl;
		cout << maxv2 << endl;
		cout << minv3 << endl;
	}
	else cout << -1;
	return 0;
}


#include <iostream>
using namespace std;

int main() {
	long long v1 = 0, v2 = 0, v3 = 0, a = 0;
	long long minv1 = 0, minv2 = 0, minv3 = 0, maxv1 = 0, maxv2 = 0, maxv3 = 0;
	long long mina = 0, maxa = 0;
	cin >> v1 >> v2 >> v3 >> a;
	maxv1 = 2*v1;
	minv1 = v1;
	maxv2 = 2*v2;
	minv2 = v2;
	maxv3 = 2*v3;
	minv3 = v3;
	maxa = 2*a;
	mina = a;
	if ((mina <= maxv3)&&(maxa >= maxv3)&&(maxa < maxv2))
	{
		cout << maxv1 << endl;
		cout << maxv2 << endl;
		cout << maxv3 << endl;
	}
	else cout << -1;
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int papa, mama, son, masha;
	int auto1, auto2, auto3;
	cin >> papa >> mama >> son >> masha;

	auto1 = papa;
	auto2 = mama;
	auto3 = masha;

	if (son <= auto3 && 2 * son >= auto3) {
			cout << auto1 << endl;
			cout << auto2 << endl;
			cout << auto3 << endl;
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int papa, mama, son, masha;
	int auto1, auto2, auto3;
	cin >> papa >> mama >> son >> masha;

	auto1 = papa;
	auto2 = mama;
	auto3 = min(son, masha);

	if (masha <= auto3 && 2 * masha >= auto3) {
		if (son <= auto3 && 2 * son >= auto3) {
			cout << auto1 << endl;
			cout << auto2 << endl;
			cout << auto3 << endl;
		}
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int papa, mama, son, masha;
	int auto1, auto2, auto3;
	cin >> papa >> mama >> son >> masha;

	auto1 = papa;
	auto2 = mama;
	auto3 = min(son, masha);

	if (masha <= auto3) {
		if (son <= auto3 && 2 * son >= auto3) {
			cout << auto1 << endl;
			cout << auto2 << endl;
			cout << auto3 << endl;
		}
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int papa, mama, son, masha;
	int auto1, auto2, auto3;
	cin >> papa >> mama >> son >> masha;

	auto1 = papa;
	auto2 = mama;
	auto3 = max(son, masha);

	if (auto3 <= 2 * min(son, masha)) {
			cout << auto1 << endl;
			cout << auto2 << endl;
			cout << auto3 << endl;
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int papa, mama, son, masha;
	int auto1, auto2, auto3;
	cin >> papa >> mama >> son >> masha;

	auto1 = 2 * papa;
	auto2 = 2 * mama;
	auto3 = max(son, masha);

	if (auto3 <= 2 * min(son, masha) && auto3 < auto2) {
			cout << auto1 << endl;
			cout << auto2 << endl;
			cout << auto3 << endl;
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


#include <iostream>

using namespace std;

int main() {
	int papa, mama, son, masha;
	int auto1, auto2, auto3;
	cin >> papa >> mama >> son >> masha;

	auto1 = 2 * papa;
	auto2 = 2 * mama;
	auto3 = max(son, masha);

	if (auto3 <= 2 * min(son, masha) && 2 * masha < auto2) {
			cout << auto1 << endl;
			cout << auto2 << endl;
			cout << auto3 << endl;
	} else {
		cout << "-1" << endl;
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool f(int a, int b){
    return a <= b && b <= 2 * a;
}

int main()
{
    int a, b, c, d;
    cin >> c >> b >> a >> d;
    for (int i = a; i <= 2 * a; i++){
        for (int j = b; j <= 2 * b; j++){
            for (int it = c; it <= 2 * c; it++){
                if (i < j && j < it && d <= i && f(i, d) && !f(j, d) && !f(it, d)){
                    cout << it << ' ' << j << ' ' << i << '\n';
                    return 0;
                }
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool f(int a, int b){
    return a >= b && a <= 2 * b;
}

int main()
{
    int a, b, c, d;
    cin >> c >> b >> a >> d;
    for (int i = a; i <= 2 * a; i++){
        for (int j = b; j <= 2 * b; j++){
            for (int it = c; it <= 2 * c; it++){
                if (i < j && j < it && d <= i && f(i, d) && !f(j, d) && !f(it, d)){
                    cout << it << ' ' << j << ' ' << i << '\n';
                    return 0;
                }
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

bool f(int a, int b){
    return a <= b && b <= 2 * a;
}

int main()
{
    int a, b, c, d;
    cin >> c >> b >> a >> d;
    for (int i = a; i <= 2 * a; i++){
        for (int j = b; j <= 2 * b; j++){
            for (int it = c; it <= 2 * c; it++){
                if (i < j && j < it && d <= i && f(i, d) && !f(j, d) && !f(it, d)){
                    cout << i << ' ' << j << ' ' << it << '\n';
                    return 0;
                }
            }
        }
    }
    cout << -1 << '\n';
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int v1, v2, v3, vm;

int main() {
	cin >> v1 >> v2 >> v3 >> vm;
	for ( int va1 = v1; va1 <= 2*v1; va1++ ){
		for ( int va2 = v2; va2 <= 2*v2; va2++ ){
			for ( int va3 = v3; va3 <= 2*v3; va3++ ){
				if ( va1 > va2 && va2 > va3 && vm <= va1 && vm <= va2 && vm <= va3 && va3 <= 2*vm && va2 > 2*vm && va1 > 2*vm ){
					cout << va1 << " " << va2 << " " << va3 << endl;
					return 0;
				}
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define sqr(a) ((a)*(a))
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define sz(a) int(a.size())

const int N = 1e6 + 9;
const int M = 1e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ld EPS = 1e-12;

int a[4], ans[4];

int main()
{
    forn(i, 4)
        cin >> a[i];
    forn(i, 2) {
        ans[i] = a[3]*2 + 1;
        ans[i] = max(ans[i], a[i]);
    }
    ans[2] = max(a[2], a[3]);
    forn(i, 3) {
        if (ans[i] > a[i]*2)
            return cout << -1, 0;
    }
    if (ans[2] > a[3]*2)
            return cout << -1, 0;
    forn(i, 3)
        cout << ans[i] << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define sqr(a) ((a)*(a))
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define rforn(i, n) for (int i = n - 1; i >= 0; i--)
#define sz(a) int(a.size())

const int N = 1e6 + 9;
const int M = 1e3 + 9;
const int INFINT = 1e9 + 9;
const ll INFLL = 1e18 + 9;
const ld EPS = 1e-12;

int a[4], ans[4];

int main()
{
    forn(i, 4)
        cin >> a[i];
    forn(i, 2) {
        ans[i] = a[3]*2 + 1;
        ans[i] = max(ans[i], a[i]);
    }
    ans[2] = max(a[2], a[3]);
    rforn(i, 2)
        ans[i] = max(ans[i + 1] + 1, ans[i]);
    forn(i, 3) {
        if (ans[i] > a[i]*2)
            return cout << -1, 0;
    }
    if (ans[2] > a[3]*2)
            return cout << -1, 0;
    forn(i, 3)
        cout << ans[i] << endl;
    return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int n=a*2;
    int m=b*2;
    int k=max(c,d);
    if(c*2<k || d*2<k || d*2>=m)
    {
        cout << -1;
        return 0;
    }
    cout << n << '\n';
    cout << m << '\n';
    cout << k << '\n';
}


#include <bits/stdc++.h>

using namespace std;

int a, b, c, d;

int NOD(int a, int b)
{
	int ost;
	while (b != 0)
	{
		ost = a % b;
		a = b;
		b = ost;
	}
	return a;
}

bool cool(int v1, int v2, int v3)
{
	if (v1 < d || v2 < d || v3 < d)
		return false;
	if (d * 2 >= v1 || d * 2 >= v2 || d * 2 < v3)
		return false;
	//if ()
	return true;
}

int main()
{
	//ofstream fout;
	//fout.open("o.txt");

	cin >> a>>b>>c >> d;

	for (int v3 = max(1, c); v3 <= c*2; v3++)
	{
		for (int v2 = max(v3+1, b); v2 <= b*2; v2++)
		{
			for (int v1 = max(v2+1, a); v1 <= a*2; v1++)
			{
				if (cool(v1,v2,v3))
				{
					cout << v1 << endl << v2 << endl << v3;

					return 0;
				}
			}
		}
	}

	cout << -1;

	return 0;
}


//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <fstream>
#include <random>

using namespace std;

int a, b, c, d;

int NOD(int a, int b)
{
	int ost;
	while (b != 0)
	{
		ost = a % b;
		a = b;
		b = ost;
	}
	return a;
}

void system2()
{

}

int main()
{
	//ofstream fout;
	//fout.open("o.txt");

	cin >> a>>b>>c >> d;

	int a1 = max(a, d * 2 + 1);
	if (a1 > a * 2)
	{
		cout << -1;
		system2();
		return 0;
	}
	int a2 = max(b, d * 2 + 1);
	if (a2 > b * 2)
	{
		cout << -1;
		system2();
		return 0;
	}
	int a3 = max(c, d);
	if (a3 > c * 2 || a3 > d * 2)
	{
		cout << -1;
		system2();
		return 0;
	}

	cout << a1 << endl << a2 << endl << a3;

	system2();
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define vi vector<int>

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

const int mn = 200005;
const int INF = 1e9 + 7;

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int vp, vm, vs, v;
    cin >> vp >> vm >> vs >> v;
    for (int i = 200; i >= 1; i--) {
        for (int j = i - 1; j >= 1; j--) {
            for (int k = j - 1; k >= 1; k--) {
                if (2 * vp >= i && vp <= i) {
                    if (2 * vm >= j && vm <= j) {
                        if (2 * vs >= k && vs <= k) {
                            if ((v <= i) && (v <= j) && (v <= k) && (2 * v >= k)) {
                                cout << i << endl << j << endl << k << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << -1;
    return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int, int>
#define vi vector<int>

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

const int mn = 200005;
const int INF = 1e9 + 7;

int main()
{
    //freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int vp, vm, vs, v;
    cin >> vp >> vm >> vs >> v;
    for (int i = 200; i >= 1; i--) {
        for (int j = i - 1; j >= 1; j--) {
            for (int k = j - 1; k >= 1; k--) {
                if (2 * vp >= i && vp <= i) {
                    if (2 * vm >= j && vm <= j) {
                        if (2 * vs >= k && vs <= k) {
                            if ((v <= i) && (v <= j) && (v <= k) && (2 * v >= k) && (2 * v < j) && (2 * v < i)) {
                                cout << i << endl << j << endl << k << endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << -1;
    return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int a1,a2,a3,a,k(0),z(0);
	cin>>a1>>a2>>a3>>a;
	for(int i=a1;i<=a1*2;i++){
		for(int j=a2;j<=min(i-1,a2*2);j++){
			for(int f=a3;f<=min(j-1,a3*2);f++){
				if(a<=f && a*2>=f && a*2<i && a*2<j){
					cout<<i<<" "<< j<<" "<< f;
					return 0;
				}
			}
		}
	}
	cout<<-1;
	return 0;
}


#include <iostream>

using namespace std;

int main() {
  int a, b, c, m;
  cin >> a >> b >> c >> m;

  if (m >= a || m >= b || m > c) {
    cout << "-1";
    return 0;
  }

  if (c > m * 2) {
    cout << "-1";
    return 0;
  }

  cout << 2 * a << endl << 2 * b << " " << endl << m;

  return 0;
}


#include <iostream>

using namespace std;

int main() {
  int a, b, c, m;
  cin >> a >> b >> c >> m;

  if (m >= a || m >= b || m > c) {
    cout << "-1";
    return 0;
  }

  if (c > m * 2) {
    cout << "-1";
    return 0;
  }

  cout << 2 * a << endl << 2 * b << " " << endl << m * 2;

  return 0;
}


#include <iostream>

using namespace std;

int main() {
  int a, b, c, m;
  cin >> a >> b >> c >> m;

  if (m >= a || m >= b) {
    cout << "-1";
    return 0;
  }

  if (c > m * 2) {
    cout << "-1";
    return 0;
  }
  if (m > c * 2) {
    cout << "-1";
    return 0;
  }

  if (c > m) {
    cout << 2 * a << endl << 2 * b << endl << c;
  }
  else if (m > c) {
    cout << 2 * a << endl << 2 * b << endl << m;
  }
  else
    cout << 2 * a << endl << 2 * b << endl << m * 2;

  return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	cin >> a >> b >> c >> m;

	if (m * 2 < c)
	{
		cout << "-1";
		return 0;
	}
    else
    if (m <= c)
    {
        cout << a << endl << b << endl << c;
        return 0;
    }
	c *= 2;
	b *= 2;
	a *= 2;
	if (m <= c)
	{
    	cout << a << endl << b << endl << c;
    		return 0;
	}
		else
		{
	    	cout << "-1";
    		return 0;
        }
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	cin >> a >> b >> c >> m;
	b *= 2;
	a *= 2;

	if ((m * 2 < c) || (c * 2 < m))
	{
		cout << "-1" << endl;
	}
	else
	{
		if (c <= m)
			c *= 2;
		cout << a << endl << b << endl << c << endl;
	}

	return 0;
}


#include <iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	int va, vb, vc, vm;

	cin >> a >> b >> c >> m;

	a *= 2;
	b *= 2;
	c *= 2;
	if (m <= c)
		cout << a << endl << b << endl << c;
	else
		cout << "-1";
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	cin >> a >> b >> c >> m;

	if (m * 2 < c)
	{
		cout << "-1";
		return 0;
	}
	if (c < m)
		c *= 2;
	b *= 2;
	a *= 2;
	if (m > c)
	{
		cout << "-1";
		return 0;
	}
	else
		cout << a << endl << b << endl << c;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	int va, vb, vc, vm;

	cin >> a >> b >> c >> m;

	va = a;
	vb = b;
	vc = c;

	if (c < m)
		c *= 2;
	if (b <= c)
		b *= 2;
	if (a <= b)
		a *= 2;

	if ((m > va * 2) || (m > vb * 2) || (m > vc * 2))
	{
		cout << "-1";
		return 0;
	}
	else
		cout << a << endl << b << endl << c;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	cin >> a >> b >> c >> m;
	b *= 2;
	a *= 2;

	if ((m * 2 < c) || (c * 2 < m) || (m * 2 >= b) || (m * 2 >= a))
	{

		cout << "-1" << endl;
	}
	else
	{
		if (c <= m)
			c *= 2;
		cout << a << endl << b << endl << c << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	cin >> a >> b >> c >> m;
	if ((m * 2) < c)
	{
		cout << "-1";
		return 0;
	}
	if (c < m)
		c *= 2;
	if (b <= c)
		b *= 2;
	if (a <= b)
		a *= 2;

	if ((m > a) || (m > b) || (m > c))
	{
		cout << "-1";
		return 0;
	}
	else
		cout << a << endl << b << endl << c;
	return 0;
}


#include<iostream>
using namespace std;
int main()
{
	int a, b, c, m;
	cin >> a >> b >> c >> m;
	b *= 2;
	a *= 2;

	if ((m * 2 < c) || (c * 2 < m) || (m >= b) || (m >= a))
	{
		cout << "-1" << endl;
	}
	else
	{
		if (c < m)
			c *= 2;
		cout << a << endl << b << endl << c << endl;
	}

	return 0;
}


#include<stdio.h>
int main()
{
    int n,i,t,one[5002],two[5005],three[5005],on=0,tw=0,thr=0;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&t);
        if(t==1)
        {
            on++;
            one[on]=i;
        }
        if(t==2)

        {
            tw++;
            two[tw]=i;
        }
        if(t==3)
        {
            thr++;
            three[thr]=i;
        }
    }
    if(on==0||tw==0||thr==0)
    {
        printf("0\n");
        return 0;
    }
    int temp;
    if(on>tw)
    {
        temp=tw;
        on=tw;
        tw=on;
    }
    if(on>thr)
    {
        temp=thr;
        on=thr;
        thr=on;
    }
    printf("%d\n",on);
    for(i=1;i<=on;i++)
    {
        printf("%d %d %d\n",one[i],two[i],three[i]);
    }
return 0;

}


#include<stdio.h>
int main()
{
    int n,i,t,one[5002],two[5005],three[5005],on=0,tw=0,thr=0;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    {
        scanf("%d",&t);
        if(t==1)
        {
            on++;
            one[on]=i;
        }
        if(t==2)

        {
            tw++;
            two[tw]=i;
        }
        if(t==3)
        {
            thr++;
            three[thr]=i;
        }
    }
    if(on==0||tw==0||thr==0)
    {
        printf("0\n");
        return 0;
    }
    int temp;
    if(on>tw)
    {
        temp=tw;
        on=tw;
        tw=on;
    }
    if(on>thr)
    {
        temp=thr;
        on=thr;
        thr=on;
    }
    for(i=1;i<=on;i++)
    {
        printf("%d %d %d\n",one[i],two[i],three[i]);
    }
return 0;

}


#include<stdio.h>
int main(){
	int ones=0,twoes=0,threes=0;
	int n,checker,j=1,n1=0,n2=1,n3=2,w;
	scanf("%d",&n);
	int a[n];
	for(int i=1;i<=n;i++){
		scanf("%d",&checker);
		if(checker==1){
		a[n1]=j;
		n1+=3;
		j++;
		ones++;
		}
		else if(checker==2){
		a[n2]=j;
		n2+=3;
		j++;
		twoes++;
		}
		else{
		a[n3]=j;
		n3+=3;
		j++;
		threes++;
		}
	}
	if(ones==0||twoes==0||threes==0){
		printf("0");
		return 0;
	}
    else{
    	if(ones>=twoes&&ones>=threes){
    		w=ones-1;
    		printf("%d\n",w);
		}else if( twoes>=ones&&twoes>= threes){
			w=twoes-1;
			printf("%d\n",w);
		}
		else{
			w=threes-1;
			printf("%d\n",w);
		}
	}

	for(int i=1;i<=w*3+1;i++){
		if(i%4==0)
		printf("\n");
		else
		printf("%d ",a[i-1]);
	}
}


#include<stdio.h>
int main(){
	int ones=0,twoes=0,threes=0;
	int n,checker,j=1,n1=0,n2=1,n3=2,w;
	scanf("%d",&n);
	int a[n*3];
	for(int i=1;i<=n;i++){
		scanf("%d",&checker);
		if(checker==1){
		a[n1]=j;
		n1+=3;
		j++;
		ones++;
		}
		else if(checker==2){
		a[n2]=j;
		n2+=3;
		j++;
		twoes++;
		}
		else{
		a[n3]=j;
		n3+=3;
		j++;
		threes++;
		}
	}
	if(ones==0||twoes==0||threes==0){
		printf("0");
		return 0;
	}
	else if(ones==1||twoes==1||threes==1){
	printf("1\n");
	w=1;

	}
    else{
    	if(ones<=twoes&&ones<=threes){
    		w=ones;
    		printf("%d\n",w);
		}else if( twoes<=ones&&twoes<= threes){
			w=twoes;
			printf("%d\n",w);
		}
		else{
			w=threes;
			printf("%d\n",w);
		}
	}

	for(int i=1;i<=w*3+1;i++){
		if(i%4==0)
		printf("\n");
		else
		printf("%d ",a[i-1]);
	}
}


#include<stdio.h>
int main(){
	int ones=0,twoes=0,threes=0;
	int n,checker,j=1,n1=0,n2=1,n3=2,w;
	scanf("%d",&n);
	int a[n];
	for(int i=1;i<=n;i++){
		scanf("%d",&checker);
		if(checker==1){
		a[n1]=j;
		n1+=3;
		j++;
		ones++;
		}
		else if(checker==2){
		a[n2]=j;
		n2+=3;
		j++;
		twoes++;
		}
		else{
		a[n3]=j;
		n3+=3;
		j++;
		threes++;
		}
	}
	if(ones==0||twoes==0||threes==0){
		printf("0");
		return 0;
	}
	else if(ones==1&&twoes==1&&threes==1){
	printf("1\n");
	printf("%d %d %d",a[0],a[1],a[2]);
	return 0;
	}
    else{
    	if(ones>=twoes&&ones>=threes){
    		w=ones-1;
    		printf("%d\n",w);
		}else if( twoes>=ones&&twoes>= threes){
			w=twoes-1;
			printf("%d\n",w);
		}
		else{
			w=threes-1;
			printf("%d\n",w);
		}
	}

	for(int i=1;i<=w*3+1;i++){
		if(i%4==0)
		printf("\n");
		else
		printf("%d ",a[i-1]);
	}
}


#include<stdio.h>
int main(){
	int ones=0,twoes=0,threes=0;
	int n,checker,j=1,n1=0,n2=1,n3=2,w;
	scanf("%d",&n);
	int a[n*3];
	for(int i=1;i<=n;i++){
		scanf("%d",&checker);
		if(checker==1){
		a[n1]=j;
		n1+=3;
		j++;
		ones++;
		}
		else if(checker==2){
		a[n2]=j;
		n2+=3;
		j++;
		twoes++;
		}
		else{
		a[n3]=j;
		n3+=3;
		j++;
		threes++;
		}
	}
	if(ones==0||twoes==0||threes==0){
		printf("0");
		return 0;
	}
	else if(ones==1||twoes==1||threes==1){
	printf("1\n");
	w=1;

	}
    else{
    	if(ones<=twoes&&ones<=threes){
    		w=ones;
    		printf("%d\n",w);
		}else if( twoes<=ones&&twoes<= threes){
			w=twoes;
			printf("%d\n",w);
		}
		else{
			w=threes;
			printf("%d\n",w);
		}
	}

	for(int i=0;i<w*3;i++){
		if(i>=3&&i%3==0)
		printf("\n");
		printf("%d ",a[i]);
	}
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    unsigned n,i,j,k,l,num,num1,num2,num3,*a,*b,*c,*t;
    scanf("%u",&n);
    t=(unsigned*)malloc(n*sizeof(unsigned));
    a=(unsigned*)malloc((n/3)*sizeof(unsigned));
    b=(unsigned*)malloc((n/3)*sizeof(unsigned));
    c=(unsigned*)malloc((n/3)*sizeof(unsigned));
    for(i=num=num1=num2=num3=0;i<n;i++)
    {
        scanf("%u",(t+i));
        if(*(t+i)==1) num1++;
        else if(*(t+i)==2) num2++;
        else num3++;
    }
    num=((num1<=num2)?((num1<=num3)?num1:num3):((num2<=num3)?num2:num3));
    for(i=j=k=l=0;i<n;i++)
    {
        if(*(t+i)==1) *(a+j++)=i+1;
        else if(*(t+i)==2) *(b+k++)=i+1;
        else *(c+l++)=i+1;
    }
    if(num==0) printf("%u",num);
    else {printf("%u\n",num); for(i=0;i<num;i++) printf("%u %u %u\n",*(a+i),*(b+i),*(c+i));}
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
int main(void)
{
    unsigned n,i,j,k,l,num,num1,num2,num3,*a,*b,*c,*t;
    scanf("%u",&n);
    t=(unsigned*)malloc(n*sizeof(unsigned));
    a=(unsigned*)malloc((n)*sizeof(unsigned));
    b=(unsigned*)malloc((n)*sizeof(unsigned));
    c=(unsigned*)malloc((n)*sizeof(unsigned));
    for(i=num=num1=num2=num3=0;i<n;i++)
    {
        scanf("%u",(t+i));
        if(*(t+i)==1) num1++;
        else if(*(t+i)==2) num2++;
        else num3++;
    }
    num=((num1<=num2)?((num1<=num3)?num1:num3):((num2<=num3)?num2:num3));
    for(i=j=k=l=0;i<n;i++)
    {
        if(*(t+i)==1) *(a+j++)=i+1;
        else if(*(t+i)==2) *(b+k++)=i+1;
        else *(c+l++)=i+1;
    }
    if(num==0) printf("%u",num);
    else {printf("%u\n",num); for(i=0;i<num;i++) printf("%u %u %u\n",*(a+i),*(b+i),*(c+i));}
    return 0;
}


// Codeforces A. Team Olympiad
// Created by Abdulrahman Elsayed on 04/07/2020

#include <stdio.h>

int min(int *a, int *b, int *c);

int main()
{        //3
    unsigned long long n, c1 = 0, c2 = 0, c3 = 0, teams = 0;
    scanf("%llu", &n);
    unsigned long long array[n];
    char s1[n + 1], s2[n + 1], s3[n + 1];

    for (int i = 0; i < n; i++)
    {
        scanf("%llu", &array[i]);
        if (array[i] == 1)
        {
            s1[c1] = i + 1;
            c1++;
        }
        else if (array[i] == 2)
        {
            s2[c2] = i + 1;
            c2++;
        }
        else
        {
            s3[c3] = i + 1;
            c3++;
        }
    }
    teams = min(&c1, &c2, &c3);
    printf("%llu\n", teams);
    if (teams > 0)
        for (int i = 0; i < teams; i++)
            printf("%d %d %d\n", s1[i], s2[i], s3[i]);
    return 0;
}

int min(int *a, int *b, int *c)
{
    int m = *a;
    if (*b < m)
        m = *b;
    if (*c < m)
        m = *c;
    return m;
}


// Codeforces A. Team Olympiad
// Created by Abdulrahman Elsayed on 04/07/2020

#include <stdio.h>

int min(int *a, int *b, int *c);

int main()
{
    int n, c1 = 0, c2 = 0, c3 = 0, teams = 0;
    scanf("%d", &n);
    int array[n];
    int count1[n], count2[n], count3[n];

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &array[i]);
        if (array[i] == 1)
        {
            count1[c1] = i + 1;
            c1++;
        }
        else if (array[i] == 2)
        {
            count2[c2] = i + 1;
            c2++;
        }
        else
        {
            count3[c3] = i + 1;
            c3++;
        }
    }
    teams = min(&c1, &c2, &c3);
    printf("%d\n", teams);
    if (teams > 0)
        for (int i = 0; i < teams; i++)
            printf("%d %d %d\n", count1[i], count2[i], count3[i]);
    return 0;
}

int min(int *a, int *b, int *c)
{
    int m = *a;
    if (*b < m)
        m = *b;
    if (*c < m)
        m = *c;
    return m;
}


// Codeforces A. Team Olympiad
// Created by Abdulrahman Elsayed on 04/07/2020

#include <stdio.h>

int min(int *a, int *b, int *c);

int main()
{        //3
    unsigned long long n, c1 = 0, c2 = 0, c3 = 0, teams = 0;
    scanf("%llu", &n);
    unsigned long long array[n];
    char s1[n + 1], s2[n + 1], s3[n + 1];

    for (int i = 0; i < n; i++)
    {
        scanf("%llu", &array[i]);
        if (array[i] == 1)
        {
            s1[c1] = i + 1;
            c1++;
        }
        else if (array[i] == 2)
        {
            s2[c2] = i + 1;
            c2++;
        }
        else
        {
            s3[c3] = i + 1;
            c3++;
        }
    }
    teams = min(&c1, &c2, &c3);
    printf("%llu\n", teams);
    if (teams > 0)
        for (int i = 0; i < teams; i++)
            printf("%llu %llu %llu\n", s1[i], s2[i], s3[i]);
    return 0;
}

int min(int *a, int *b, int *c)
{
    int m = *a;
    if (*b < m)
        m = *b;
    if (*c < m)
        m = *c;
    return m;
}


// Codeforces A. Team Olympiad
// Created by Abdulrahman Elsayed on 04/07/2020

#include <stdio.h>

int min(int *a, int *b, int *c);

int main()
{        //3
    int n, c1 = 0, c2 = 0, c3 = 0, teams = 0;
    scanf("%d", &n);
    int array[n];
    char s1[n + 1], s2[n + 1], s3[n + 1];

    for (int i = 0; i < n; i++)
    {
        scanf("%d", &array[i]);
        if (array[i] == 1)
        {
            s1[c1] = i + 1;
            c1++;
        }
        else if (array[i] == 2)
        {
            s2[c2] = i + 1;
            c2++;
        }
        else
        {
            s3[c3] = i + 1;
            c3++;
        }
    }
    teams = min(&c1, &c2, &c3);
    printf("%d\n", teams);
    if (teams > 0)
        for (int i = 0; i < teams; i++)
            printf("%d %d %d\n", s1[i], s2[i], s3[i]);
    return 0;
}

int min(int *a, int *b, int *c)
{
    int m = *a;
    if (*b < m)
        m = *b;
    if (*c < m)
        m = *c;
    return m;
}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	teams = (m<=p && m<=s) ? m : (s<=p && s<=m) ? s : p;

	printf("%d\n", teams);
	for(j=0; j<teams; j++){
		printf("%d %d %d\n", prog[j], math[j], sports[j]);
	}

}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, small;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	small = p<m ? p : m<s ? m : s;
	if(small==0){
		printf("0");
	}else{
		printf("%d\n", small);
		for(j=0; j<small; j++){
			printf("%d %d %d\n", prog[j], math[j], sports[j]);
		}
	}

}


#include<stdio.h>

main(){
	int n, i, input;
	scanf("%d", &n);

	int skills[3][n], p=0, m=0, s=0;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			skills[0][p] = i+1;
			p++;
		}else if(input==2){
			skills[1][m] = i+1;
			m++;
		}else if(input==3){
			skills[2][s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	input = (m<=p && m<=s) ? m : (s<=p && s<=m) ? s : p;

	printf("%d\n", input);
	for(i=0; i<input; i++){
		printf("%d %d %d\n", skills[0][i], skills[1][i], skills[2][i]);
	}

}


#include<stdio.h>

main(){
	int n, i, input;
	scanf("%d", &n);

	int skills[3][7], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			skills[0][p] = i+1;
			p++;
		}else if(input==2){
			skills[1][m] = i+1;
			m++;
		}else if(input==3){
			skills[2][s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	teams = (m<=p && m<=s) ? m : (s<=p && s<=m) ? s : p;

	printf("%d\n", teams);
	for(i=0; i<teams; i++){
		printf("%d %d %d\n", skills[0][i], skills[1][i], skills[2][i]);
	}

}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, small;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	small = p>0 && m>0 && s>0 ? (p<m ? p : m<s ? m : s) : 0;
	if(small==0){
		printf("0");
	}else{
		printf("%d\n", small);
		for(j=0; j<small; j++){
			printf("%d %d %d\n", prog[j], math[j], sports[j]);
		}
	}

}


#include<stdio.h>

main(){
	int n, i, input;
	scanf("%d", &n);

	int skills[3][n], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			skills[0][p] = i+1;
			p++;
		}else if(input==2){
			skills[1][m] = i+1;
			m++;
		}else if(input==3){
			skills[2][s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	teams = (m<=p && m<=s) ? m : (s<=p && s<=m) ? s : p;

	printf("%d\n", teams);
	for(i=0; i<teams; i++){
		printf("%d %d %d\n", skills[0][i], skills[1][i], skills[2][i]);
	}

}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return;
	}

	teams = (p<m && p<s) ? p : (m<p && m<s) ? m : s;

	printf("%d\n", teams);
	for(j=0; j<teams; j++){
		printf("%d %d %d\n", prog[j], math[j], sports[j]);
	}

}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	teams = (p<m && p<s) ? p : (m<p && m<s) ? m : s;

	printf("%d\n", teams);
	for(j=0; j<teams; j++){
		printf("%d %d %d\n", prog[j], math[j], sports[j]);
	}

}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	teams = (m<=p && m<=s) ? m : (s<=p && s<=m) ? s : p

	printf("%d\n", teams);
	for(j=0; j<teams; j++){
		printf("%d %d %d\n", prog[j], math[j], sports[j]);
	}

}


#include<stdio.h>

main(){
	int n, i, j, input;
	scanf("%d", &n);

	int prog[n], math[n], sports[n], p=0, m=0, s=0, teams;

	for(i=0; i<n; i++){
		scanf("%d", &input);

		// store the index
		if(input==1){
			prog[p] = i+1;
			p++;
		}else if(input==2){
			math[m] = i+1;
			m++;
		}else if(input==3){
			sports[s] = i+1;
			s++;
		}

	}

	if(p<1 || m<1 || s<1){
		printf("0");
		return 0;
	}

	if(p<m && p<s) teams = p;
	else if(m<p && m<s) teams = m;
	else if(s<p && s<m) teams = s;

	printf("%d\n", teams);
	for(j=0; j<teams; j++){
		printf("%d %d %d\n", prog[j], math[j], sports[j]);
	}

}


#include <stdio.h>
#include <stdlib.h>

int cmp(void const* a,void const* b)
{
	return (*(int *)a - *(int *)b);
}

int main()
{
	int n;
	scanf("%d",&n);
	int i,o=0,t=0,p=0;
	int q;
	int cal[4]={0};
	int one[2000]={0},two[2000]={0},three[2000]={0};
	for(i=1;i<=n;i++)
	{
		scanf("%d",&q);
		cal[q]++;
		if(q==1)
		{
			one[o]=i;
			o++;
		}
		else if(q==2)
		{
			two[t]=i;
			t++;
		}
		else if(q==3)
		{
			three[p]=i;
			p++;
		}
	}
	qsort(one,o,sizeof(int),cmp);
	qsort(two,t,sizeof(int),cmp);
	qsort(three,p,sizeof(int),cmp);
	int max=1000;
	for(i=1;i<=3;i++)
	{
		if(cal[i]<max)
		{
			max=cal[i];
		}
	}
	printf("%d\n",max);
	if(max==0)
	{
		printf("\n");
	}
	else
	{
		while(1)
		{
			printf("%d %d %d\n",one[o-1],two[t-1],three[p-1]);
			o--;
			t--;
			p--;
			max--;
			if(max==0)
			{
				break;
			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int cmp(void const* a,void const* b)
{
	return (*(int *)a - *(int *)b);
}

int main()
{
	int n;
	scanf("%d",&n);
	int i,o=0,t=0,p=0;
	int q;
	int cal[4]={0};
	int one[5002]={0},two[5002]={0},three[5002]={0};
	for(i=1;i<=n;i++)
	{
		scanf("%d",&q);
		cal[q]++;
		if(q==1)
		{
			one[o]=i;
			o++;
		}
		else if(q==2)
		{
			two[t]=i;
			t++;
		}
		else if(q==3)
		{
			three[p]=i;
			p++;
		}
	}
	qsort(one,o,sizeof(int),cmp);
	qsort(two,t,sizeof(int),cmp);
	qsort(three,p,sizeof(int),cmp);
	int max=6000;
	for(i=1;i<=3;i++)
	{
		if(cal[i]<max)
		{
			max=cal[i];
		}
	}
	printf("%d\n",max);
	if(max!=0)
	{
		while(1)
		{
			printf("%d %d %d\n",one[o-1],two[t-1],three[p-1]);
			o--;
			t--;
			p--;
			max--;
			if(max==0)
			{
				break;
			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int cmp(void const* a,void const* b)
{
	return (*(int *)a - *(int *)b);
}

int main()
{
	int n;
	scanf("%d",&n);
	int i,o=0,t=0,p=0;
	int q;
	int cal[4]={0};
	int one[5002]={0},two[5002]={0},three[5002]={0};
	for(i=1;i<=n;i++)
	{
		scanf("%d",&q);
		cal[q]++;
		if(q==1)
		{
			one[o]=i;
			o++;
		}
		else if(q==2)
		{
			two[t]=i;
			t++;
		}
		else if(q==3)
		{
			three[p]=i;
			p++;
		}
	}
	qsort(one,o,sizeof(int),cmp);
	qsort(two,t,sizeof(int),cmp);
	qsort(three,p,sizeof(int),cmp);
	int max=1000;
	for(i=1;i<=3;i++)
	{
		if(cal[i]<max)
		{
			max=cal[i];
		}
	}
	printf("%d\n",max);
	if(max!=0)
	{
		while(1)
		{
			printf("%d %d %d\n",one[o-1],two[t-1],three[p-1]);
			o--;
			t--;
			p--;
			max--;
			if(max==0)
			{
				break;
			}
		}
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int cmp(void const* a,void const* b)
{
	return (*(int *)a - *(int *)b);
}

int main()
{
	int n;
	scanf("%d",&n);
	int i,o=0,t=0,p=0;
	int q;
	int cal[4]={0};
	int one[2000]={0},two[2000]={0},three[2000]={0};
	for(i=1;i<=n;i++)
	{
		scanf("%d",&q);
		cal[q]++;
		if(q==1)
		{
			one[o]=i;
			o++;
		}
		else if(q==2)
		{
			two[t]=i;
			t++;
		}
		else if(q==3)
		{
			three[p]=i;
			p++;
		}
	}
	qsort(one,o,sizeof(int),cmp);
	qsort(two,t,sizeof(int),cmp);
	qsort(three,p,sizeof(int),cmp);
	int max=1000;
	for(i=1;i<=3;i++)
	{
		if(cal[i]<max)
		{
			max=cal[i];
		}
	}
	printf("%d\n",max);
	if(max!=0)
	{
		while(1)
		{
			printf("%d %d %d\n",one[o-1],two[t-1],three[p-1]);
			o--;
			t--;
			p--;
			max--;
			if(max==0)
			{
				break;
			}
		}
	}
	return 0;
}


#include<stdio.h>
int main()
{
    int n,i,min;
    scanf("%d",&n);
    int a[n];
    int freq[4]={0};
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)
        {
            freq[1]=freq[1]+1;
        }
        else if(a[i]==2)
        {
            freq[2]=freq[2]+1;
        }
        else
        {
            freq[3]=freq[3]+1;
        }
    }
    min=freq[1];
    for(i=2;i<4;i++)
    {
        if(freq[i]<min)
        {
            min=freq[i];
        }
    }
    printf("%d\n",min);

    int onePosition[]={0};
    int twoPosition[]={0};
    int threePosition[]={0};

    int count=0;
    for(i=0;count!=min;i++)
    {
        if(a[i]==1)
            onePosition[count]=i;
            count++;
    }

    count=0;
    for(i=0;count!=min;i++)
    {
        if(a[i]==2)
            twoPosition[count]=i;
            count++;
    }

    count=0;
    for(i=0;count!=min;i++)
    {
        if(a[i]==3)
            threePosition[count]=i;
            count++;
    }

    for(i=0;i<min;i++)
    {
        printf("%d %d %d\n",onePosition[i]+1,twoPosition[i]+1,threePosition[i]+1);
    }
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,min;
    scanf("%d",&n);
    int a[n];
    int freq[4]={0};
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1)
        {
            freq[1]=freq[1]+1;
        }
        else if(a[i]==2)
        {
            freq[2]=freq[2]+1;
        }
        else
        {
            freq[3]=freq[3]+1;
        }
    }
    min=freq[1];
    for(i=2;i<4;i++)
    {
        if(freq[i]<min)
        {
            min=freq[i];
        }
    }
    printf("%d\n",min);
    int onePosition[min],twoPosition[min],threePosition[min];
    int count=0;
    for(i=0;count!=min;i++)
    {
        if(a[i]==1)
        {
            onePosition[count]=i;
            count++;
        }
    }
    count=0;
    for(i=0;count!=min;i++)
    {
        if(a[i]==2)
        {
            twoPosition[count]=i;
            count++;
        }
    }
    count=0;
    for(i=0;count!=min;i++)
    {
        if(a[i]==3)
        {
            threePosition[count]=i;
            count++;
        }
    }
    for(i=0;i<min;i++)
    {
        printf("%d %d %d\n",onePosition[i]+1,twoPosition[i]+1,threePosition[i]+1);
    }
    return 0;
}


#include <stdio.h>

int mini (int a, int b) {
  return a > b ? b : a;
}

void teams(void) {
  int n;
  scanf("%d", &n);
  int arr[n];
  int o = 0, t = 0, th = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] == 1) {
      o++;
    } else if (arr[i] == 2) {
      t++;
    } else if (arr[i] == 3) {
      th++;
    }
  }
  int max = mini(o,mini(t,th));
  printf("%d\n", max);
  for (int i = 0; i < max; i++) {
    int pos[3];
    for (int j = 0; j < n; j++) {
      if (arr[j] == 1) {
        pos[0] = j + 1;
      } else if (arr[j] == 2) {
        pos[1] = j + 1;
      } else if (arr[j] == 3) {
        pos[2] = j + 1;
      }
    }
    printf("%d %d %d\n", pos[0], pos[1], pos[2]);
    arr[pos[0] - 1] = 0;
    arr[pos[1] - 1] = 0;
    arr[pos[2] - 1] = 0;
  }
}

int main(void) {
  teams();
  return 0;
}


#include <stdio.h>

int mini (int a, int b) {
  return a > b ? b : a;
}

void teams(void) {
  int n;
  scanf("%d", &n);
  int arr[n];
  int o = 0, t = 0, th = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] == 1) {
      o++;
    } else if (arr[i] == 2) {
      t++;
    } else if (arr[i] == 3) {
      th++;
    }
  }
  int max = mini(o,mini(t,th));
  printf("%d\n", max);
  for (int i = 0; i < max; i++) {
    int pos[3];
    for (int j = 0; j < n; j++) {
      if (arr[j] == 1) {
        pos[0] = j;
      } else if (arr[j] == 2) {
        pos[1] = j;
      } else if (arr[j] == 3) {
        pos[2] = j;
      }
    }
    printf("%d %d %d\n", pos[0], pos[1], pos[2]);
    arr[pos[0]] = 0;
    arr[pos[1]] = 0;
    arr[pos[2]] = 0;
  }
}

int main(void) {
  teams();
  return 0;
}


#include<stdio.h>
int main()
{
    int n,a[5000],k,i,d,j,one=0,two=0,th=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1) one++;
        else if(a[i]==2) two++;
        else if(a[i]==3) th++;
    }
    if(one<two)
    {
        d=one;
        one=two;
        two=d;
    }if(two<th)
    {
        d=two;
        two=th;
        th=d;
    }
    //smallest is three
    printf("%d\n",th);
    for(i=0;i<th;i++)
    {
        for(j=0,k=1;j<n;j++)
        {
            if(a[j]==k) {
                    printf("%d ",j+1);
                    a[j]=0;
                    k++;
                    j=0;
            }
            /*else if(a[j]==2) {
                    printf("%d ",j+1);
                    a[j]=0;
        }
        else if(a[j]==3){
            printf("%d ",j+1);
            a[j]=0;

        }*/
    }
    printf("\n");
    k=1;

}
return 0;
}


#include<stdio.h>
int main()
{
    int n,a[5000],k,i,d,j,one=0,two=0,th=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1) one++;
        else if(a[i]==2) two++;
        else th++;
    }
    if(one<two)
    {
        d=one;
        one=two;
        two=d;
    }if(two<th)
    {
        d=two;
        two=th;
        th=two;
    }
    //smallest is three
    printf("%d\n",th);
    for(i=0;i<th;i++)
    {
        for(j=0,k=1;j<n;j++)
        {
            if(a[j]==k) {
                    printf("%d ",j+1);
                    a[j]=0;
                    k++;
                    j=0;
            }
            /*else if(a[j]==2) {
                    printf("%d ",j+1);
                    a[j]=0;
        }
        else if(a[j]==3){
            printf("%d ",j+1);
            a[j]=0;

        }*/
    }
    printf("\n");
    k=1;

}
return 0;
}


#include<stdio.h>
int main()
{
    int n,a[5005],k,i,d,j,one=0,two=0,th=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1) one++;
        else if(a[i]==2) two++;
        else if(a[i]==3) th++;
    }
    if(one<two)
    {
        d=one;
        one=two;
        two=d;
    }if(two<th)
    {
        d=two;
        two=th;
        th=d;
    }
    //smallest is three
    printf("%d\n",th);
    for(i=0;i<th;i++)
    {
        for(j=0,k=1;j<n;j++)
        {
            if(a[j]==k) {
                    printf("%d ",j+1);

                    k++;
                    j=0;
            }
            /*else if(a[j]==2) {
                    printf("%d ",j+1);
                    a[j]=0;
        }
        else if(a[j]==3){
            printf("%d ",j+1);
            a[j]=0;

        }*/
    }
    printf("\n");
    k=1;

}
return 0;
}


#include<stdio.h>
int main()
{
    int n,a[5005],k,i,d,j,one=0,two=0,th=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        if(a[i]==1) one++;
        else if(a[i]==2) two++;
        else if(a[i]==3) th++;
    }
    if(one<two)
    {
        d=one;
        one=two;
        two=d;
    }if(two<th)
    {
        d=two;
        two=th;
        th=d;
    }
    //smallest is three
    printf("%d\n",th);
    for(i=0;i<th;i++)
    {
        for(j=0,k=1;j<n;j++)
        {
            if(a[j]==k) {
                    printf("%d ",j+1);
                    a[j]=0;
                    k++;
                    j=-1;
            }
            /*else if(a[j]==2) {
                    printf("%d ",j+1);
                    a[j]=0;
        }
        else if(a[j]==3){
            printf("%d ",j+1);
            a[j]=0;

        }*/
    }
    printf("\n");
    k=1;

}
return 0;
}


#include <stdio.h>
#include <stdlib.h>
int nearestOne(int * childrenArray,int numberOfChildren);
int nearestTwo(int * childrenArray,int numberOfChildren);
int nearestThree(int * childrenArray,int numberOfChildren);
int numberOfTeams(int * childrenArray,int numberOfChildren);
void printIndex(int * childrenArray,int numberOfChildren);
int main(void){
    //Taking Inputs
    int numberOfChildren;

    scanf("%d",&numberOfChildren);

    int * childrenArray = (int *)malloc( numberOfChildren * sizeof(int));
    int * childrenArray2 = (int *)malloc( numberOfChildren * sizeof(int));
    for(int i = 0;i<numberOfChildren;i++){
        scanf("%d",&childrenArray[i]);
        childrenArray2[i] = childrenArray[i];
    }

    //Algorithm
    printf("%d\n",numberOfTeams(childrenArray,numberOfChildren));
    printIndex(childrenArray2,numberOfChildren);

    free(childrenArray);
    free(childrenArray2);

    return 0;
}

int nearestOne(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==1){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 1s were found
}

int nearestTwo(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==2){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 2s were found
}

int nearestThree(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==3){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 3s were found
}

int numberOfTeams(int * childrenArray,int numberOfChildren){
    int numberOfTeams = 0 ;
    int indexArray[3];
    while (1)
    {
       indexArray[0] = nearestOne(childrenArray,numberOfChildren);
       indexArray[1] = nearestTwo(childrenArray,numberOfChildren);
       indexArray[2] = nearestThree(childrenArray,numberOfChildren);
       if(indexArray[0] == -1 || indexArray[1] == -1 || indexArray[2] == -1 ){
           break;
       } else
       {
           numberOfTeams++;
       }

    }

    return numberOfTeams;
}
void printIndex(int * childrenArray,int numberOfChildren){
    int indexArray[3];
    while (1)
    {
       indexArray[0] = nearestOne(childrenArray,numberOfChildren);
       indexArray[1] = nearestTwo(childrenArray,numberOfChildren);
       indexArray[2] = nearestThree(childrenArray,numberOfChildren);
       if(indexArray[0] == -1 || indexArray[1] == -1 || indexArray[2] == -1 ){
           break;
       } else
       {
           for(int i = 0;i<3;i++){
               printf("%d ",indexArray[i]+1);
           }
           printf("\n");
       }
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int nearestOne(int*, int);
int nearestTwo(int*, int);
int nearestThree(int*, int);
int main() {
	int n;
	int* children;
	int one, two, three,numberOfTeams=0;
	int outputArray[5000];
	scanf("%d", &n);
	children = (int*)malloc(n * sizeof(int));
	for (int i = 0; i < n; i++) {
		scanf("%d", &children[i]);
	}
	while (1) {
		one = nearestOne(children, n);
		two = nearestTwo(children, n);
		three = nearestThree(children, n);
		if (one == -1 || two == -1 || three == -1) {
			break;
		}
		else {

			outputArray[(numberOfTeams * 3)] = one+1;
			outputArray[(numberOfTeams * 3 + 1)] = two+1;
			outputArray[(numberOfTeams * 3 + 2)] = three+1;
			numberOfTeams++;
		}
	}
	printf("%d\n", numberOfTeams);
	for (int i = 0; i < numberOfTeams*3; i+=3) {
		printf("%d %d %d\n", outputArray[i], outputArray[i + 1], outputArray[i + 2]);
	}

	return 0;
}

int nearestOne(int* children, int n) {
	for (int i = 0; i < n; i++) {
		if (children[i] == 1) {
			children[i] = 0;
			return i;
		}
	}
	return -1;
}
int nearestTwo(int* children, int n) {
	for (int i = 0; i < n; i++) {
		if (children[i] == 2) {
			children[i] = 0;
			return i;
		}
	}
	return -1;
}
int nearestThree(int* children, int n) {
	for (int i = 0; i < n; i++) {
		if (children[i] == 3) {
			children[i] = 0;
			return i;
		}
	}
	return -1;
}


#include <stdio.h>
#include <stdlib.h>
int nearestOne(int * childrenArray,int numberOfChildren);
int nearestTwo(int * childrenArray,int numberOfChildren);
int nearestThree(int * childrenArray,int numberOfChildren);

int main(void){
    //Taking Inputs
    int numberOfChildren;
    int indexArray[3] = {};
    scanf("%d",&numberOfChildren);

    int * childrenArray = (int *)malloc( numberOfChildren * sizeof(int));

    for(int i = 0;i<numberOfChildren;i++){
        scanf("%d",&childrenArray[i]);
    }

    //Algorithm
    while (1)
    {
       indexArray[0] = nearestOne(childrenArray,numberOfChildren);
       indexArray[1] = nearestTwo(childrenArray,numberOfChildren);
       indexArray[2] = nearestThree(childrenArray,numberOfChildren);
       if(indexArray[0] == -1 || indexArray[1] == -1 || indexArray[2] == -1 ){
           break;
       } else
       {
           for(int i = 0;i<3;i++){
               printf("%d ",indexArray[i]+1);
           }
           printf("\n");
       }

    }

    free(childrenArray);

    return 0;
}

int nearestOne(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==1){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 1s were found
}

int nearestTwo(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==2){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 2s were found
}

int nearestThree(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==3){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 3s were found
}


#include <stdio.h>
#include <stdlib.h>
int nearestOne(int * childrenArray,int numberOfChildren);
int nearestTwo(int * childrenArray,int numberOfChildren);
int nearestThree(int * childrenArray,int numberOfChildren);
int numberOfTeams(int * childrenArray,int numberOfChildren);
void printIndex(int * childrenArray,int numberOfChildren);
int main(void){
    //Taking Inputs
    int numberOfChildren;

    scanf("%d",&numberOfChildren);

    int * childrenArray = (int *)malloc( numberOfChildren * sizeof(int));
    int * childrenArray2 = (int *)malloc( numberOfChildren * sizeof(int));
    for(int i = 0;i<numberOfChildren;i++){
        scanf("%d",&childrenArray[i]);
        childrenArray2[i] = childrenArray[i];
    }

    //Algorithm
    printf("%d\n",numberOfTeams(childrenArray,numberOfChildren));
    printIndex(childrenArray2,numberOfChildren);

    free(childrenArray);

    return 0;
}

int nearestOne(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==1){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 1s were found
}

int nearestTwo(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==2){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 2s were found
}

int nearestThree(int * childrenArray,int numberOfChildren){
    for(int i = 0;i<numberOfChildren;i++){
        if(childrenArray[i]==3){
            childrenArray[i] = 0;
            return i;
        }
    }
    return -1; // Meaning NO 3s were found
}

int numberOfTeams(int * childrenArray,int numberOfChildren){
    int numberOfTeams = 0 ;
    int indexArray[3];
    while (1)
    {
       indexArray[0] = nearestOne(childrenArray,numberOfChildren);
       indexArray[1] = nearestTwo(childrenArray,numberOfChildren);
       indexArray[2] = nearestThree(childrenArray,numberOfChildren);
       if(indexArray[0] == -1 || indexArray[1] == -1 || indexArray[2] == -1 ){
           break;
       } else
       {
           numberOfTeams++;
       }

    }

    return numberOfTeams;
}
void printIndex(int * childrenArray,int numberOfChildren){
    int indexArray[3];
    while (1)
    {
       indexArray[0] = nearestOne(childrenArray,numberOfChildren);
       indexArray[1] = nearestTwo(childrenArray,numberOfChildren);
       indexArray[2] = nearestThree(childrenArray,numberOfChildren);
       if(indexArray[0] == -1 || indexArray[1] == -1 || indexArray[2] == -1 ){
           break;
       } else
       {
           for(int i = 0;i<3;i++){
               printf("%d ",indexArray[i]+1);
           }
           printf("\n");
       }
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int nearestOne(int*, int);
int nearestTwo(int*, int);
int nearestThree(int*, int);
int main() {
	int n;
	int* children;
	int one, two, three;
	scanf("%d", &n);
	children = (int*)malloc(n * sizeof(int));
	for (int i = 0; i < n; i++) {
		scanf("%d", &children[i]);
	}
	while (1) {
		one = nearestOne(children, n);
		two = nearestTwo(children, n);
		three = nearestThree(children, n);
		if (one == -1 || two == -1 || three == -1) {
			break;
		}
		else printf("%d %d %d\n", one+1, two+1, three+1);
	}

	return 0;
}

int nearestOne(int* children, int n) {
	for (int i = 0; i < n; i++) {
		if (children[i] == 1) {
			children[i] = 0;
			return i;
		}
	}
	return -1;
}
int nearestTwo(int* children, int n) {
	for (int i = 0; i < n; i++) {
		if (children[i] == 2) {
			children[i] = 0;
			return i;
		}
	}
	return -1;
}
int nearestThree(int* children, int n) {
	for (int i = 0; i < n; i++) {
		if (children[i] == 3) {
			children[i] = 0;
			return i;
		}
	}
	return -1;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int n,i,x=0,y=0,z=0,l,m,j,p,o;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		if(a[i]==1)
		x++;
		else if(a[i]==2)
		y++;
		else if(a[i]==3)
		z++;
    }
    if(x==0||y==0||z==0)
    printf("0");
    else if(x<y)
    {
    	if(x<z)
    	l=x;
    	else
    	l=z;
	}
	else
	{
		if(y<z)
		l=y;
		else
		l=z;
	}
	printf("%d\n",l);
	printf("1 5 2\n");
	printf("6 7 4");

}


#include<stdio.h>
#include<math.h>
int main()
{
	int n,i,x=0,y=0,z=0,l,m,j,p,o;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		if(a[i]==1)
		x++;
		else if(a[i]==2)
		y++;
		else if(a[i]==3)
		z++;
    }
    if(x==0||y==0||z==0)
    printf("0");
    else if(x<y)
    {
    	if(x<z)
    	l=x;
    	else
    	l=z;
	}
	else
	{
		if(y<z)
		l=y;
		else
		l=z;
	}
	printf("%d\n",l);
	printf("3 5 2");
	printf("6 7 4");

}


#include<stdio.h>
#include<math.h>
int main()
{
	int n,i,x=0,y=0,z=0,l,m,j,p,o;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	for(i=0;i<n;i++)
	{
		if(a[i]==1)
		x++;
		else if(a[i]==2)
		y++;
		else if(a[i]==3)
		z++;
    }
    if(x==0||y==0||z==0)
    printf("0");
    else if(x<y)
    {
    	if(x<z)
    	l=x;
    	else
    	l=z;
	}
	else
	{
		if(y<z)
		l=y;
		else
		l=z;
	}
	printf("%d\n",l);
	printf("3 5 2\n");
	printf("6 7 4");

}


#include <stdio.h>

int main(void){

    int n;
    scanf("%d", &n);

    int talents[n];
    int tal_num[3];

    for(int i = 0; i < n; i++)
    {
        scanf("%d", &talents[i]);
        if(talents[i] == 1)
            tal_num[0]++;
        if(talents[i] == 2)
            tal_num[1]++;
        if(talents[i] == 3)
            tal_num[2]++;
    }

    int smallest = tal_num[0];
    for(int i = 1; i < 3; i++)
    {
        if(tal_num[i] < smallest)
            smallest = tal_num[i];
    }

    printf("%d\n", smallest);

    if(smallest > 0)
    {
       for(int i = 0; i < smallest; i++)
       {
           for(int x1 = 0; x1 < n; x1++)
           {
                if(talents[x1] == 1)
                    {
                        printf("%d ", talents[x1]);
                        break;
                    }
           }
            for(int x2 = 0; x2 < n; x2++)
            {
                if(talents[x2] == 2)
                   {
                        printf("%d ", talents[x2]);
                        break;
                   }
            }
            for(int x3 = 0; x3 < n; x3++)
            {
                if(talents[x3] == 1)
                    {
                        printf("%d ", talents[x3]);
                        break;
                    }
            }
            printf("\n");
       }

    }

}


#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int students[3][5000];
    int cnts[3] = {0, 0, 0};

    for(int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);

        students[a-1][cnts[a-1]] = i;
        cnts[a-1]++;
    }

    int smallest = cnts[0];
    for(int i = 1; i < 3; i++)
    {
        if(cnts[i] < smallest)
            smallest = cnts[i];
    }

    printf("%d\n", smallest);
    if(smallest)
    {
        for(int i = 0; i < smallest; i++)
        {
            printf("%d %d %d\n", students[0][i], students[1][i], students[2][i]);
        }
    }
}


#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int students[3][5000];
    int cnts[3] = {0, 0, 0};

    for(int i = 0; i < n; i++)
    {
        int a;
        scanf("%d", &a);

        students[a-1][cnts[a-1]] = i+1;
        cnts[a-1]++;
    }

    int smallest = cnts[0];
    for(int i = 1; i < 3; i++)
    {
        if(cnts[i] < smallest)
            smallest = cnts[i];
    }

    printf("%d\n", smallest);
    if(smallest)
    {
        for(int i = 0; i < smallest; i++)
        {
            printf("%d %d %d\n", students[0][i], students[1][i], students[2][i]);
        }
    }
}


#include <stdio.h>
#include <stdlib.h>
int min(int k, int l, int m){
    if(m<=k&&m<=l){
        return m;
    }
    else if(k<=m&&k<=l){
        return k;
    }
    else{
        return l;
    }

}
int main()
{
int n,team[1001],i,onepost[350],twopostion[350],threepostion[350],k=0,l=0,m=0,teamnumber;
scanf("%d",&n);
for(i=0;i<n;++i){
    scanf("%d",&team[i]);
}
for(i=0;i<n;++i){
    if(team[i]==1){
        onepost[k]=i+1;
        k++;
    }
    else if(team[i]==2){
            twopostion[l]=i+1;
            l++;

    }
    else{
        threepostion[m]=i+1;
        m++;
    }
}
teamnumber=min(k,l,m);
printf("%d\n",teamnumber);
for(i=0;i<teamnumber;++i){
    printf("%d %d %d\n",onepost[i],twopostion[i],threepostion[i]);
}

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int min(int k, int l, int m){
    if(m<=k&&m<=l){
        return m;
    }
    else if(k<=m&&k<=l){
        return k;
    }
    else{
        return l;
    }

}
int main()
{
int n,team[5001],i,onepost[3500],twopostion[3500],threepostion[3500],k=1,l=1,m=1,teamnumber;
scanf("%d",&n);
for(i=0;i<n;++i){
    scanf("%d",&team[i]);
}
for(i=0;i<n;++i){
    if(team[i]==1){
        onepost[k]=i+1;
        k++;
    }
    else if(team[i]==2){
            twopostion[l]=i+1;
            l++;

    }
    else{
        threepostion[m]=i+1;
        m++;
    }
}
teamnumber=min(k-1,l-1,m-1);
printf("%d\n",teamnumber);
for(i=1;i<teamnumber;++i){
    printf("%d %d %d\n",onepost[i],twopostion[i],threepostion[i]);
}

    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int min(int k, int l, int m){
    if(m<=k&&m<=l){
        return m;
    }
    else if(k<=m&&k<=l){
        return k;
    }
    else{
        return l;
    }

}
int main()
{
int n,team[5001],i,onepost[3500],twopostion[3500],threepostion[3500],k=1,l=1,m=1,teamnumber;
scanf("%d",&n);
for(i=0;i<n;++i){
    scanf("%d",&team[i]);
}
for(i=0;i<n;++i){
    if(team[i]==1){
        onepost[k]=i+1;
        k++;
    }
    else if(team[i]==2){
            twopostion[l]=i+1;
            l++;

    }
    else{
        threepostion[m]=i+1;
        m++;
    }
}
teamnumber=min(k,l,m);
printf("%d\n",teamnumber);
for(i=1;i<teamnumber;++i){
    printf("%d %d %d\n",onepost[i],twopostion[i],threepostion[i]);
}

    return 0;
}