#include <iostream>

using namespace std;

struct Pair{
    long a;
    long b;
};

long abs(long a)
{
    return a>0?a:-a;
}

void qsort(Pair array[100000], int firstIndex, int secondIndex)
{
    Pair mainEl = array[firstIndex];
    int l = firstIndex;
    int r = secondIndex;

    while (l < r)
    {

        while ((abs(array[l].a) < abs(mainEl.a)) || ((abs(array[l].a) == abs(mainEl.a)) && (abs(array[l].b) < abs(mainEl.b))))
        {
            l++;
        }

        while ((abs(array[l].a) > abs(mainEl.a)) || ((abs(array[l].a) == abs(mainEl.a)) && (abs(array[l].b) > abs(mainEl.b))))

        {
            r--;
        }

        if (l <= r)
        {
            Pair changer;
            changer.a = array[l].a;
            changer.b = array[l].b;
            array[l] = array[r];
            array[r] = changer;
            l++;
            r--;
        }

    }

    if (r > firstIndex)
    {
        qsort(array, firstIndex, r);
    }

    if (secondIndex > l)
    {
        qsort(array, l, secondIndex);
    }
}

int main()
{
    int n;
    cin >> n;
    Pair arP[100000];
    int number = 0;
    for (int i = 0; i < n; ++i)
    {
        long t, k;
        cin >> t >> k;
        Pair op;
        op.a = t;
        op.b = k;
        arP[i] = op;

        if ((op.a != 0) && (op.b != 0))
        {
            number++;
        }
    }

    qsort(arP, 0 , n -1);
            cout << number * 6 + (n - number) * 4 << "\n";

            for (int i  = 0; i < n; ++i)
        {
            if (arP[i].a > 0)
            {

                cout << "1 " << abs(arP[i].a) << " R\n";
                if (arP[i].b > 0)
                {
                    cout << "1 " << abs(arP[i].b) << " U\n";
                    cout << "2\n";
                    cout << "1 " << abs(arP[i].b) << " D\n";

                }
                else
                {   if (arP[i].b < 0) {
                    cout << "1 " << abs(arP[i].b) << " D\n";
                    cout << "2\n";
                    cout << "1 " << abs(arP[i].b) << " U\n";
                    }
                    else    cout << "2\n";

                }
                cout << "1 " << abs(arP[i].a) << " L\n";

            }
            else
            {
                if (arP[i].a < 0) {
                cout << "1 " << abs(arP[i].a) << " L\n";
                if (arP[i].b > 0)
                {
                    cout << "1 " << abs(arP[i].b) << " U\n";
                    cout << "2\n";
                    cout << "1 " << abs(arP[i].b) << " D\n";

                }
                else
                {
                 if (arP[i].b < 0) {

                    cout << "1 " << abs(arP[i].b) << " D\n";
                    cout << "2\n";
                    cout << "1 " << abs(arP[i].b) << " U\n";
                    } else  cout << "2\n";

                }
                cout << "1 " << abs(arP[i].a) << " R\n";
                } else
                {
                if (arP[i].b > 0)
                {
                    cout << "1 " << abs(arP[i].b) << " U\n";
                    cout << "2\n";
                    cout << "1 " << abs(arP[i].b) << " D\n";

                }
                else
                {
                 if (arP[i].b < 0) {

                    cout << "1 " << abs(arP[i].b) << " D\n";
                    cout << "2\n";
                    cout << "1 " << abs(arP[i].b) << " U\n";
                    } else  cout << "2\n";

                }
            }
            }
            cout << "3\n";

    }
    return 0;
}


#include <iostream>

using std::cin;
using std::cout;

struct Pair{
    long a;
    long b;
};

long abs2(int a)
{
    return a>0?a:-a;
}

void qsort(Pair array[100000], int firstIndex, int secondIndex)
{
    Pair mainEl = array[firstIndex];
    int l = firstIndex;
    int r = secondIndex;

    while (l < r)
    {

        while ((abs2(array[l].a) < abs2(mainEl.a))   || ((abs2(array[l].a) == abs2(mainEl.a)) && (abs2(array[l].b) < abs2(mainEl.b))))
        {
            l++;
        }

        while ((abs2(array[r].a) > abs2(mainEl.a))  || ((abs2(array[r].a) == abs2(mainEl.a)) && (abs2(array[r].b) > abs2(mainEl.b))))

        {
            r--;
        }

        if (l <= r)
        {
            Pair changer;
            changer.a = array[l].a;
            changer.b = array[l].b;
            array[l] = array[r];
            array[r] = changer;
            l++;
            r--;
        }

    }

    if (r > firstIndex)
    {
        qsort(array, firstIndex, r);
    }

    if (secondIndex > l)
    {
        qsort(array, l, secondIndex);
    }
}

int main()
{
    int n;
    cin >> n;
    Pair arP[100000];
    int number = 0;
    for (int i = 0; i < n; ++i)
    {
        long t, k;
        cin >> t;
        cin >> k;
        Pair op;
        op.a = t;
        op.b = k;
        arP[i] = op;

        if ((op.a != 0) && (op.b != 0))
        {
            number++;
        }
    }

    qsort(arP, 0 , n-1);

            cout << number * 6 + (n - number) * 4 << "\n";

            for (int i  = 0; i < n; ++i)
            {
            if (arP[i].a > 0)
            {

                cout << "1 " << arP[i].a << " R\n";
                if (arP[i].b > 0)
                {
                    cout << "1 " << arP[i].b << " U\n";
                    cout << "2\n";
                    cout << "1 " << arP[i].b << " D\n";

                }
                else
                {   if (arP[i].b < 0) {
                    cout << "1 " << -arP[i].b << " D\n";
                    cout << "2\n";
                    cout << "1 " << -arP[i].b << " U\n";
                    }
                    else    cout << "2\n";

                }
                cout << "1 " << arP[i].a << " L\n";

            }
            else
            {
                if (arP[i].a < 0) {
                cout << "1 " << -arP[i].a << " L\n";
                if (arP[i].b > 0)
                {
                    cout << "1 " << arP[i].b << " U\n";
                    cout << "2\n";
                    cout << "1 " << arP[i].b << " D\n";

                }
                else
                {
                 if (arP[i].b < 0) {

                    cout << "1 " << -arP[i].b << " D\n";
                    cout << "2\n";
                    cout << "1 " << -arP[i].b << " U\n";
                    } else  cout << "2\n";

                }
                cout << "1 " << -arP[i].a << " R\n";
                } else
                {
                if (arP[i].b > 0)
                {
                    cout << "1 " << arP[i].b << " U\n";
                    cout << "2\n";
                    cout << "1 " << arP[i].b << " D\n";

                }
                else
                {
                 if (arP[i].b < 0) {

                    cout << "1 " << -arP[i].b << " D\n";
                    cout << "2\n";
                    cout << "1 " << -arP[i].b << " U\n";
                    } else  cout << "2\n";

                }
            }
        }
        cout << "3\n";

    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
struct mm
{
	int x , y ;
	bool operator <( const mm &s )const
	{
		return x < s.x || x == s.x&&y < s.y ;
	}
}qq[maxn/10] ;
int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 3 ;
		}
	}
}
void out() ;
int main()
{
	int n , x,  y , i ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		for( i = 0 ; i < n ;i++ )
		{
			scanf("%d%d" , &qq[i].x , &qq[i].y) ;
		}
		sort(qq,qq+n) ;
		for( i = 0 ; i < n ;i++ )
		{
			getans(qq[i].x,qq[i].y) ;
		}
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
struct mm
{
	int x , y ;
	bool operator <( const mm &s )const
	{
		return x*x+y*y < s.x*s.x+s.y*s.y ;
	}
}qq[maxn/10] ;

int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		qe[len++].id = 2 ;
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 3 ;
		}

	}
}
void out() ;
int main()
{
	int n , x,  y , i ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		for( i = 0 ; i < n ;i++ )
		{
			scanf("%d%d" , &qq[i].x , &qq[i].y) ;
		}
		sort(qq,qq+n) ;
		for( i = 0 ; i < n ;i++ )
		{
			getans(qq[i].x,qq[i].y) ;
		}
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
struct mm
{
	int x , y ;
	bool operator <( const mm &s )const
	{
		return x < s.x || x == s.x && y < s.y ;
	}
}qq[maxn/10] ;

int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		qe[len++].id = 2 ;
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 3 ;
		}

	}
}
void out() ;
int find( int n , int &y )
{
	int L , R ,mid ;
	L = 0 ; R = n ;
	while( L <= R )
	{
		mid = (L+R)>>1 ;
		if( qq[mid].x == 0 )  break  ;
		if( qq[mid].x > 0) R = mid-1 ;
		else L = mid+1 ;
	}
	int i ;y = 0 ;
	if( qq[mid].x != 0 ) return mid ;
	for(  i = mid ; i < n ;i++ )if(qq[i].x != 0 )break;
	y = i ;
	for(  i = mid ; i >= 0 ;i-- )if( qq[i].x != 0)break ;
	return i ;
}
int main()
{
	int n , x,  y , i ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		for( i = 0 ; i < n ;i++ )
		{
			scanf("%d%d" , &qq[i].x , &qq[i].y) ;
		}
		sort(qq,qq+n) ;
        x = find(n-1,y) ;
		//cout << x << " " << y << endl ;
		for( i = x+1 ; i < y ;i++)getans(qq[i].x,qq[i].y) ;
		if( y != 0 )
		for( i = y ; i < n ;i++ )getans(qq[i].x,qq[i].y) ;
		for( i = x ; i >= 0 ;i--)getans(qq[i].x,qq[i].y) ;
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
struct mm
{
	int x , y ;
	bool operator <( const mm &s )const
	{
		return abs(x) < abs(s.x) || abs(x) == abs(s.x)&&abs(y) < abs(s.y) ;
	}
}qq[maxn/10] ;
int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		qe[len++].id = 2 ;
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 3 ;
		}

	}
}
void out() ;
int main()
{
	int n , x,  y , i ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		for( i = 0 ; i < n ;i++ )
		{
			scanf("%d%d" , &qq[i].x , &qq[i].y) ;
		}
		sort(qq,qq+n) ;
		for( i = 0 ; i < n ;i++ )
		{
			getans(qq[i].x,qq[i].y) ;
		}
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 3 ;
		}
	}
}
void out() ;
int main()
{
	int n , x,  y ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		while(n--)
		{
			scanf("%d%d" , &x , &y ) ;
			getans(x,y) ;
		}
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
struct mm
{
	int x , y ;
	bool operator <( const mm &s )const
	{
		return x < s.x || x == s.x&&y < s.y ;
	}
}qq[maxn/10] ;
int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		qe[len++].id = 2 ;
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 3 ;
		}

	}
}
void out() ;
int main()
{
	int n , x,  y , i ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		for( i = 0 ; i < n ;i++ )
		{
			scanf("%d%d" , &qq[i].x , &qq[i].y) ;
		}
		sort(qq,qq+n) ;
		for( i = 0 ; i < n ;i++ )
		{
			getans(qq[i].x,qq[i].y) ;
		}
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<stack>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std ;

#define maxn 1000010
struct node
{
	int id , mun ;
	char a ;
}qe[maxn] ;
struct mm
{
	int x , y ;
	bool operator <( const mm &s )const
	{
		return x < s.x || x == s.x && y < s.y ;
	}
}qq[maxn/10] ;

int len ;
void getans( int x , int y )
{
	if( y == 0 )
	{
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
			qe[len++].id = 2 ;
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
			qe[len++].id = 2 ;
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R';
			qe[len++].id = 3 ;
		}
		return ;
	}
	else if( x == 0 )
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 2 ;
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D';
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 2 ;
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U';
			qe[len++].id = 3 ;
		}
	}
	else
	{
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
		}
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		qe[len++].id = 2 ;
		if( x > 0 )
		{
			qe[len].mun = x ;
			qe[len].id = 1 ;
			qe[len++].a = 'L' ;
		}
		else
		{
			qe[len].mun = -x ;
			qe[len].id = 1 ;
			qe[len++].a = 'R' ;
		}
		if( y > 0 )
		{
			qe[len].mun = y ;
			qe[len].id = 1 ;
			qe[len++].a = 'D' ;
			qe[len++].id = 3 ;
		}
		else
		{
			qe[len].mun = -y ;
			qe[len].id = 1 ;
			qe[len++].a = 'U' ;
			qe[len++].id = 3 ;
		}

	}
}
void out() ;
int find( int n , int &y )
{
	int L , R ,mid ;
	L = 0 ; R = n ;
	while( L <= R )
	{
		mid = (L+R)>>1 ;
		if( qq[mid].x == 0 )  break  ;
		if( qq[mid].x > 0) R = mid-1 ;
		else L = mid+1 ;
	}
	int i ;
	for(  i = mid ; i < n ;i++ )if(qq[i].x != 0 )break;
	y = i ;
	for(  i = mid ; i >= 0 ;i-- )if( qq[i].x != 0)break ;
	return i ;
}
int main()
{
	int n , x,  y , i ;
	while( scanf("%d" , &n ) != EOF )
	{
		len = 0 ;
		for( i = 0 ; i < n ;i++ )
		{
			scanf("%d%d" , &qq[i].x , &qq[i].y) ;
		}
		sort(qq,qq+n) ;
        x = find(n-1,y) ;
		for( i = x+1 ; i < y ;i++)getans(qq[i].x,qq[i].y) ;
		for( i = y ; i < n ;i++ )getans(qq[i].x,qq[i].y) ;
		for( i = x ; i >= 0 ;i--)getans(qq[i].x,qq[i].y) ;
		out() ;
	}
}
void out()
{
	printf("%d\n" , len ) ;
	for( int i = 0 ; i < len ;i++ )
	{
		if(qe[i].id == 1 )
		{
			printf("%d %d %c\n" , qe[i].id ,qe[i].mun , qe[i].a ) ;
		}
		else printf("%d\n" , qe[i].id) ;
	}
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,xx,yy;
	cin >> n;
	vector<int>x0;
	vector<int>x01;
	map<int,vector<int>>m1;
	map<int,vector<int>>m2;
	map<int,vector<int>,greater<int>>m3;
	map<int,vector<int>,greater<int>>m4;
	int res = 0;
	for(int i = 0; i<n; i++){
		scanf("%d%d",&xx,&yy);
		if(!xx){
			res+=4;
			if (yy>0)x0.push_back(yy);else{
				x01.push_back(yy);
			}
		}else{
			res+=6;
			if (yy>=0){
				if (!yy)res-=2;
				if (xx>0){
					m1[yy].push_back(xx);
				}else{
					m2[yy].push_back(xx);
				}
			}else{
				if (xx>0){
					m4[yy].push_back(xx);
				}else{
					m3[yy].push_back(xx);
				}
			}
		}
	}
	cout << res << endl;
	sort(x0.begin(),x0.end());
	for(int i = 0; i<x0.size(); i++){
		printf("1 %d U\n",x0[i]);
		printf("2\n");
		printf("1 %d D\n",x0[i]);
		printf("3\n");
	}
	sort(x01.rbegin(),x01.rend());
	for(int i = 0; i<x01.size(); i++){
		printf("1 %d D\n",x0[i]);
		printf("2\n");
		printf("1 %d U\n",x0[i]);
		printf("3\n");
	}
	for(map<int,vector<int>>::iterator i = m1.begin(); i!=m1.end(); i++){
		sort(i->second.begin(),i->second.end());
		for(int j=0; j<i->second.size(); ++j){
			if (i->first)printf("1 %d U\n",i->first);
			printf("1 %d R\n",i->second[j]);
			printf("2\n");
			printf("1 %d L\n",i->second[j]);
			if (i->first)printf("1 %d D\n",i->first);
			printf("3\n");
		}
	}
	for(map<int,vector<int>>::iterator i = m2.begin(); i!=m2.end(); i++){
		sort(i->second.rbegin(),i->second.rend());
		for(int j=0; j<i->second.size(); ++j){
			if (i->first)printf("1 %d U\n",i->first);
			printf("1 %d L\n",abs(i->second[j]));
			printf("2\n");
			printf("1 %d R\n",abs(i->second[j]));
			if (i->first)printf("1 %d D\n",i->first);
			printf("3\n");
		}
	}
	for(map<int,vector<int>,greater<int>>::iterator i = m3.begin(); i!=m3.end(); i++){
		sort(i->second.rbegin(),i->second.rend());
		for(int j=0; j<i->second.size(); ++j){
			printf("1 %d D\n",abs(i->first));
			printf("1 %d L\n",abs(i->second[j]));
			printf("2\n");
			printf("1 %d R\n",abs(i->second[j]));
			printf("1 %d U\n",abs(i->first));
			printf("3\n");
		}
	}
	for(map<int,vector<int>,greater<int>>::iterator i = m4.begin(); i!=m4.end(); i++){
		sort(i->second.begin(),i->second.end());
		for(int j=0; j<i->second.size(); ++j){
			printf("1 %d D\n",abs(i->first));
			printf("1 %d R\n",i->second[j]);
			printf("2\n");
			printf("1 %d L\n",i->second[j]);
			printf("1 %d U\n",abs(i->first));
			printf("3\n");
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,xx,yy;
	cin >> n;
	vector<int>x0;
	vector<int>x01;
	map<int,vector<int>>m1;
	map<int,vector<int>>m2;
	map<int,vector<int>,greater<int>>m3;
	map<int,vector<int>,greater<int>>m4;
	int res = 0;
	for(int i = 0; i<n; i++){
		scanf("%d%d",&xx,&yy);
		if(!xx){
			res+=4;
			if (yy>0)x0.push_back(yy);else{
				x01.push_back(yy);
			}
		}else{
			res+=6;
			if (yy>=0){
				if (!yy)res-=2;
				if (xx>0){
					m1[yy].push_back(xx);
				}else{
					m2[yy].push_back(xx);
				}
			}else{
				if (xx>0){
					m4[yy].push_back(xx);
				}else{
					m3[yy].push_back(xx);
				}
			}
		}
	}
	cout << res << endl;
	sort(x0.begin(),x0.end());
	for(int i = 0; i<x0.size(); i++){
		printf("1 %d U\n",x0[i]);
		printf("2\n");
		printf("1 %d D\n",x0[i]);
		printf("3\n");
	}
	sort(x01.rbegin(),x01.rend());
	for(int i = 0; i<x01.size(); i++){
		printf("1 %d D\n",abs(x01[i]));
		printf("2\n");
		printf("1 %d U\n",abs(x01[i]));
		printf("3\n");
	}
	for(map<int,vector<int>>::iterator i = m1.begin(); i!=m1.end(); i++){
		sort(i->second.begin(),i->second.end());
		for(int j=0; j<i->second.size(); ++j){
			if (i->first)printf("1 %d U\n",i->first);
			printf("1 %d R\n",i->second[j]);
			printf("2\n");
			printf("1 %d L\n",i->second[j]);
			if (i->first)printf("1 %d D\n",i->first);
			printf("3\n");
		}
	}
	for(map<int,vector<int>>::iterator i = m2.begin(); i!=m2.end(); i++){
		sort(i->second.rbegin(),i->second.rend());
		for(int j=0; j<i->second.size(); ++j){
			if (i->first)printf("1 %d U\n",i->first);
			printf("1 %d L\n",abs(i->second[j]));
			printf("2\n");
			printf("1 %d R\n",abs(i->second[j]));
			if (i->first)printf("1 %d D\n",i->first);
			printf("3\n");
		}
	}
	for(map<int,vector<int>,greater<int>>::iterator i = m3.begin(); i!=m3.end(); i++){
		sort(i->second.rbegin(),i->second.rend());
		for(int j=0; j<i->second.size(); ++j){
			printf("1 %d D\n",abs(i->first));
			printf("1 %d L\n",abs(i->second[j]));
			printf("2\n");
			printf("1 %d R\n",abs(i->second[j]));
			printf("1 %d U\n",abs(i->first));
			printf("3\n");
		}
	}
	for(map<int,vector<int>,greater<int>>::iterator i = m4.begin(); i!=m4.end(); i++){
		sort(i->second.begin(),i->second.end());
		for(int j=0; j<i->second.size(); ++j){
			printf("1 %d D\n",abs(i->first));
			printf("1 %d R\n",i->second[j]);
			printf("2\n");
			printf("1 %d L\n",i->second[j]);
			printf("1 %d U\n",abs(i->first));
			printf("3\n");
		}
	}
	return 0;
}


#include <stdio.h>
#include <iostream>
#include <vector>
#include <math.h>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;

int main(){
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	int n,xx,yy;
	cin >> n;
	vector<int>x0;
	vector<int>x01;
	map<int,vector<int>>m1;
	map<int,vector<int>>m2;
	map<int,vector<int>,greater<int>>m3;
	map<int,vector<int>,greater<int>>m4;
	int res = 0;
	for(int i = 0; i<n; i++){
		scanf("%d%d",&xx,&yy);
		if(!xx){
			res+=4;
			if (yy>0)x0.push_back(yy);else{
				x01.push_back(yy);
			}
		}else{
			res+=6;
			if (yy>=0){
				if (!yy)res-=2;
				if (xx>0){
					m1[yy].push_back(xx);
				}else{
					m2[yy].push_back(xx);
				}
			}else{
				if (xx>0){
					m4[yy].push_back(xx);
				}else{
					m3[yy].push_back(xx);
				}
			}
		}
	}
	cout << res << endl;
	sort(x0.begin(),x0.end());
	for(int i = 0; i<x0.size(); i++){
		printf("1 %d U\n",x0[i]);
		printf("2\n");
		printf("1 %d D\n",x0[i]);
		printf("3\n");
	}
	sort(x01.rbegin(),x01.rend());
	for(int i = 0; i<x01.size(); i++){
		printf("1 %d D\n",x01[i]);
		printf("2\n");
		printf("1 %d U\n",x01[i]);
		printf("3\n");
	}
	for(map<int,vector<int>>::iterator i = m1.begin(); i!=m1.end(); i++){
		sort(i->second.begin(),i->second.end());
		for(int j=0; j<i->second.size(); ++j){
			if (i->first)printf("1 %d U\n",i->first);
			printf("1 %d R\n",i->second[j]);
			printf("2\n");
			printf("1 %d L\n",i->second[j]);
			if (i->first)printf("1 %d D\n",i->first);
			printf("3\n");
		}
	}
	for(map<int,vector<int>>::iterator i = m2.begin(); i!=m2.end(); i++){
		sort(i->second.rbegin(),i->second.rend());
		for(int j=0; j<i->second.size(); ++j){
			if (i->first)printf("1 %d U\n",i->first);
			printf("1 %d L\n",abs(i->second[j]));
			printf("2\n");
			printf("1 %d R\n",abs(i->second[j]));
			if (i->first)printf("1 %d D\n",i->first);
			printf("3\n");
		}
	}
	for(map<int,vector<int>,greater<int>>::iterator i = m3.begin(); i!=m3.end(); i++){
		sort(i->second.rbegin(),i->second.rend());
		for(int j=0; j<i->second.size(); ++j){
			printf("1 %d D\n",abs(i->first));
			printf("1 %d L\n",abs(i->second[j]));
			printf("2\n");
			printf("1 %d R\n",abs(i->second[j]));
			printf("1 %d U\n",abs(i->first));
			printf("3\n");
		}
	}
	for(map<int,vector<int>,greater<int>>::iterator i = m4.begin(); i!=m4.end(); i++){
		sort(i->second.begin(),i->second.end());
		for(int j=0; j<i->second.size(); ++j){
			printf("1 %d D\n",abs(i->first));
			printf("1 %d R\n",i->second[j]);
			printf("2\n");
			printf("1 %d L\n",i->second[j]);
			printf("1 %d U\n",abs(i->first));
			printf("3\n");
		}
	}
	return 0;
}


import sys

def dist(p):
    return p[0] + p[1]

n = int(input())

pts = []
for i in range(n):
    pts.append(tuple(map(int, input().split())))

pts.sort(key=dist)

ops = []

def move(s, t, direc):
    if s == t: return
    if t > s: ops.append('1 {} {}'.format(t - s, direc[0]))
    else: ops.append('1 {} {}'.format(s - t, direc[1]))

for p in pts:
    move(0, p[0], 'RL')
    move(0, p[1], 'UD')
    ops.append('2')
    move(p[0], 0, 'RL')
    move(p[1], 0, 'UD')
    ops.append('3')

sys.stdout.write(str(len(ops))+'\n')
sys.stdout.write('\n'.join(ops))


import sys

def dist(p):
    return abs(p[0]) + abs(p[1])

n = int(input())

pts = []
for i in range(n):
    pts.append(tuple(map(int, input().split())))

pts.sort(key=dist)

ops = []

def move(s, t, direc):
    if s == t: return
    if t > s: ops.append('1 {} {}'.format(t - s, direc[0]))
    else: ops.append('1 {} {}'.format(s - t, direc[1]))

for p in pts:
    move(0, p[0], 'RL')
    move(0, p[1], 'UD')
    ops.append('2')
    move(p[0], 0, 'RL')
    move(p[1], 0, 'UD')
    ops.append('3')

sys.stdout.write(str(len(ops))+'\n')
sys.stdout.write('\n'.join(ops))


n=int(input())
d=[]
for i in range(n):
    x,y=list(map(int,input().split()))
    d.append([(x**2+y**2)**(0.5),x,y])
d.sort()
ans=[]
for i in range(n):
    if d[i][1]<0:
        ans.append('1 '+str(-d[i][1])+' L')
    elif d[i][1]>0:
        ans.append('1 '+str(d[i][1])+' R')
    if d[i][2]<0:
        ans.append('1 '+str(-d[i][2])+' D')
    elif d[i][2]>0:
        ans.append('1 '+str(d[i][2])+' U')
    ans.append('2')
    if d[i][2]<0:
        ans.append('1 '+str(abs(d[i][2]))+' U')
    elif d[i][2]>0:
        ans.append('1 '+str(abs(d[i][2]))+' D')
    if d[i][1]<0:
        ans.append('1 '+str(abs(d[i][1]))+' R')
    elif d[i][1]>0:
        ans.append('1 '+str(abs(d[i][1]))+' L')
    ans.append('3')
print(len(ans))
print('\n'.join(ans))


n=int(input())
d=[]
for i in range(n):
    x,y=list(map(int,input().split()))
    d.append([(x**2+y**2)**(0.5),x,y])
d.sort()
ans=[]
for i in range(n):
    if d[i][1]<0:
        ans.append('1 '+str(-d[i][1])+' L')
    elif d[i][1]>0:
        ans.append('1 '+str(d[i][1])+' R')
    if d[i][2]<0:
        ans.append('1 '+str(-d[i][2])+' D')
    elif d[i][2]>0:
        ans.append('1 '+str(d[i][2])+' U')
    ans.append('2')
    if d[i][2]<0:
        ans.append('1 '+str(abs(d[i][2]))+' U')
    elif d[i][2]>0:
        ans.append('1 '+str(abs(d[i][2]))+' D')
    if d[i][1]<0:
        ans.append('1 '+str(abs(d[i][1]))+' R')
    elif d[i][1]>0:
        ans.append('1 '+str(abs(d[i][1]))+' L')
    ans.append(3)
print(len(ans))
for i in range(len(ans)):
    print(ans[i])


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
sys.setrecursionlimit(100000)

n=int(data())
A=[]
A1=[]
cnt=2*n
for i in range(n):
    x,y=mdata()
    k=0
    if x<0 or y<0:
        k=1
    A.append([abs(x),abs(y),i])
    A1.append([x,y])
    if x!=0:
        cnt+=2
    if y!=0:
        cnt+=2
A=sorted(A,key=lambda x:(x[0],x[1]))
print(cnt)
for i in range(n):
    x,y,k=A[i]
    x,y=A1[k]
    if x>0:
        print(1,x,'R')
    elif x<0:
        print(1,-x,'L')
    if y> 0:
        print(1, y, 'U')
    elif y < 0:
        print(1, -y, 'D')
    print(2)
    if x>0:
        print(1,x,'L')
    elif x<0:
        print(1,-x,'R')
    if y> 0:
        print(1, y, 'D')
    elif y < 0:
        print(1, -y, 'U')
    print(3)


from bisect import bisect_left as bl, bisect_right as br, insort
import operator
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
#sys.setrecursionlimit(100000)

n=int(data())
A=[]
A1=[]
cnt=2*n
d=dd(list)
for i in range(n):
    x,y=mdata()
    A.append([abs(x)+abs(y),x,y])
    if x!=0:
        cnt+=2
    if y!=0:
        cnt+=2
print(cnt)
A.sort()
for i in A:
        a,x,y=i
        if x>0:
            print(1,x,'R')
        elif x<0:
            print(1,-x,'L')
        if y> 0:
            print(1, y, 'U')
        elif y < 0:
            print(1, -y, 'D')
        print(2)
        if x>0:
            print(1,x,'L')
        elif x<0:
            print(1,-x,'R')
        if y> 0:
            print(1, y, 'D')
        elif y < 0:
            print(1, -y, 'U')
        print(3)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
#sys.setrecursionlimit(100000)

n=int(data())
A=[]
A1=[]
cnt=2*n
d=dd(list)
for i in range(n):
    x,y=mdata()
    A.append([abs(x)+abs(y),i])
    A1.append([x,y])
    if x!=0:
        cnt+=2
    if y!=0:
        cnt+=2
print(cnt)
A=sorted(A,key=lambda x:x[0])
for i in A:
        a,k=i
        x,y=A1[k]
        if x>0:
            print(1,x,'R')
        elif x<0:
            print(1,-x,'L')
        if y> 0:
            print(1, y, 'U')
        elif y < 0:
            print(1, -y, 'D')
        print(2)
        if x>0:
            print(1,x,'L')
        elif x<0:
            print(1,-x,'R')
        if y> 0:
            print(1, y, 'D')
        elif y < 0:
            print(1, -y, 'U')
        print(3)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
#sys.setrecursionlimit(100000)

n=int(data())
A=[]
ans=[]
d=dd(list)
for i in range(n):
    x,y=mdata()
    A.append((x,y))
A.sort(key=lambda x:abs(x[0])+abs(x[1]))
for i in A:
    x,y=i
    if x > 0:
        ans.append('1 %d R' % x)
    elif x < 0:
        ans.append('1 %d L' % -x)
    if y > 0:
        ans.append('1 %d U' % y)
    elif y < 0:
        ans.append('1 %d D' % -y)
    ans.append('2')
    if x > 0:
        ans.append('1 %d L' % x)
    elif x < 0:
        ans.append('1 %d R' % -x)
    if y > 0:
        ans.append('1 %d D' % y)
    elif y < 0:
        ans.append('1 %d U' % -y)
    ans.append('3')
print(len(ans))
print('\n'.join(ans))


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
sys.setrecursionlimit(100000)

n=int(data())
A=[]
A1=[]
cnt=2*n
d=dd(list)
for i in range(n):
    x,y=mdata()
    k=0
    d[abs(x)].append([abs(y),i])
    A1.append([x,y])
    if x!=0:
        cnt+=2
    if y!=0:
        cnt+=2
print(cnt)
for i in sorted(d):
    for j in sorted(d[i],key=lambda x:x[0]):
        y,k=j
        x,y=A1[k]
        if x>0:
            print(1,x,'R')
        elif x<0:
            print(1,-x,'L')
        if y> 0:
            print(1, y, 'U')
        elif y < 0:
            print(1, -y, 'D')
        print(2)
        if x>0:
            print(1,x,'L')
        elif x<0:
            print(1,-x,'R')
        if y> 0:
            print(1, y, 'D')
        elif y < 0:
            print(1, -y, 'U')
        print(3)


from bisect import bisect_left as bl, bisect_right as br, insort
import sys
import heapq
#from math import *
from collections import defaultdict as dd, deque
def data(): return sys.stdin.readline().strip()
def mdata(): return map(int, data().split())
def print(x): return sys.stdout.write(str(x)+'\n')
#sys.setrecursionlimit(100000)

n=int(data())
A=[]
cnt=2*n
for i in range(n):
    x,y=mdata()
    A.append((x,y))
    if x != 0:
        cnt += 2
    if y != 0:
        cnt += 2
print(cnt)
A.sort(key=lambda x:abs(x[0])+abs(x[1]))
for i in A:
    x,y=i
    if x > 0:
        print('1 '+str(x)+' R')
    elif x < 0:
        print('1 '+str(-x)+' L')
    if y > 0:
        print('1 '+ str(y)+ ' U')
    elif y < 0:
        print('1 '+ str(-y)+ ' D')
    print(2)
    if x > 0:
        print('1 '+str(x)+' L')
    elif x < 0:
        print('1 '+str(-x)+' R')
    if y > 0:
        print('1 '+ str(y)+ ' D')
    elif y < 0:
        print('1 '+ str(-y)+' U')
    print(3)


def f(i, j):
    if i: print(1, abs(i), 'L' if i < 0 else 'R')
    if j: print(1, abs(j), 'U' if j > 0 else 'D')
    print(2)
    if j: print(1, abs(j), 'U' if j < 0 else 'D')
    if i: print(1, abs(i), 'L' if i > 0 else 'R')
    print(3)
n = int(input())
t = [(abs(i) + abs(j), i, j) for i, j in tuple(map(int, input().split()) for i in range(n))]
t.sort()
s = 0
for r, i, j in t:
    s += r
print(2 * (s + n))
for r, i, j in t:
    f(i, j)


def f(i, j):
    if i: print(1, abs(i), 'L' if i < 0 else 'R')
    if j: print(1, abs(j), 'U' if j > 0 else 'D')
    print(2)
    if j: print(1, abs(j), 'U' if j < 0 else 'D')
    if i: print(1, abs(i), 'L' if i > 0 else 'R')
    print(3)
n = int(input())
t = [(abs(i) + abs(j), i, j) for i, j in tuple(map(int, input().split()) for i in range(n))]
t.sort()
s = 0
for r, i, j in t:
    s += int(i != 0) + int(j != 0)
print(2 * (s + n))
for r, i, j in t:
    f(i, j)


#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mkp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 1000005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
struct operation
{
	int id;ll up,down;
}oper[MAXN];
struct cmp
{
	inline bool operator()(const operation& a,const operation& b)
	{
		return a.up*(__int128_t)b.down>b.up*(__int128_t)a.down;
	}
};
int n,m,K,cnt;
ll a[MAXN],mval[MAXN];int mtag[MAXN],type[MAXN];
vector<pair<ll,int> > ope[MAXN];
int ans[MAXN];
inline bool comp(int a,int b)
{
	return type[a]<type[b];
}
int main()
{
	n=read(),m=read(),K=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<=m;i++)
	{
		type[i]=read();int x=read(),y=read();
		if(type[i]==1)
		{
			if(mval[x]<y)
			mval[x]=y,mtag[x]=i;
		}
		if(type[i]==2)
		ope[x].pb(mkp(y,i));
		if(type[i]==3)
		oper[++cnt].id=i,oper[cnt].up=y,oper[cnt].down=1;
	}
	for(int i=1;i<=n;i++)
	if(mtag[i])
	ope[i].pb(mkp(mval[i]-a[i],mtag[i]));
	for(int i=1;i<=n;i++)
	{
		sort(ope[i].begin(),ope[i].end());
		for(int j=0;j<ope[i].size();j++)
		oper[++cnt].id=ope[i][j].sc,oper[cnt].down=a[i],oper[cnt].up=a[i]+ope[i][j].fr,a[i]+=ope[i][j].fr;
	}
	sort(oper+1,oper+cnt+1,cmp());
	int out=1;
	for(;out<=K;out++)
	{
		if(oper[out].up>oper[out].down)
		ans[out]=oper[out].id;
		else
		break;
	}
	printf("%d\n",out-1);
	sort(ans+1,ans+out,comp);
	for(int i=1;i<out;i++)
	printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mkp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 1000005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
struct operation
{
	int id;ll up,down;
}oper[MAXN];
struct cmp
{
	inline bool operator()(const operation& a,const operation& b)
	{
		return a.up*b.down>b.up*a.down;
	}
};
int n,m,K,cnt;
ll a[MAXN],mval[MAXN];int mtag[MAXN],type[MAXN];
vector<pair<ll,int> > ope[MAXN];
int ans[MAXN];
inline bool comp(int a,int b)
{
	return type[a]<type[b];
}
int main()
{
	n=read(),m=read(),K=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<=m;i++)
	{
		type[i]=read();int x=read(),y=read();
		if(type[i]==1)
		{
			if(mval[x]<y)
			mval[x]=y,mtag[x]=i;
		}
		if(type[i]==2)
		ope[x].pb(mkp(y,i));
		if(type[i]==3)
		oper[++cnt].id=i,oper[cnt].up=y,oper[cnt].down=1;
	}
	for(int i=1;i<=n;i++)
	if(mtag[i])
	ope[i].pb(mkp(mval[i]-a[i],mtag[i]));
	for(int i=1;i<=n;i++)
	{
		sort(ope[i].begin(),ope[i].end());
		reverse(ope[i].begin(),ope[i].end());
		for(int j=0;j<ope[i].size();j++)
		oper[++cnt].id=ope[i][j].sc,oper[cnt].down=a[i],oper[cnt].up=a[i]+ope[i][j].fr,a[i]+=ope[i][j].fr;
	}
	sort(oper+1,oper+cnt+1,cmp());
	int out=1;
	for(;out<=K;out++)
	{
		if(oper[out].up>oper[out].down)
		ans[out]=oper[out].id;
		else
		break;
	}
	printf("%d\n",out-1);
	sort(ans+1,ans+out,comp);
	for(int i=1;i<out;i++)
	printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mkp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 1000005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
struct operation
{
	int id;ll up,down;
}oper[MAXN];
struct cmp
{
	inline bool operator()(const operation& a,const operation& b)
	{
		return a.up/(double)a.down>b.up/(double)b.down;
	}
};
int n,m,K,cnt;
ll a[MAXN],mval[MAXN];int mtag[MAXN],type[MAXN];
vector<pair<ll,int> > ope[MAXN];
int ans[MAXN];
inline bool comp(int a,int b)
{
	return type[a]==type[b]?a<b:type[a]<type[b];
}
int main()
{
	n=read(),m=read(),K=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<=m;i++)
	{
		type[i]=read();int x=read(),y=read();
		if(type[i]==1)
		{
			if(mval[x]<y)
			mval[x]=y,mtag[x]=i;
		}
		if(type[i]==2)
		ope[x].pb(mkp(y,i));
		if(type[i]==3)
		oper[++cnt].id=i,oper[cnt].up=y,oper[cnt].down=1;
	}
	for(int i=1;i<=n;i++)
	if(mtag[i])
	ope[i].pb(mkp(mval[i]-a[i],mtag[i]));
	for(int i=1;i<=n;i++)
	{
		sort(ope[i].begin(),ope[i].end());
		reverse(ope[i].begin(),ope[i].end());
		for(int j=0;j<ope[i].size();j++)
		oper[++cnt].id=ope[i][j].sc,oper[cnt].down=a[i],oper[cnt].up=a[i]+ope[i][j].fr,a[i]+=ope[i][j].fr;
	}
	sort(oper+1,oper+cnt+1,cmp());
	int out=1;
	for(;out<=K;out++)
	{
		if(oper[out].up>oper[out].down)
		ans[out]=oper[out].id;
		else
		break;
	}
	printf("%d\n",out-1);
	sort(ans+1,ans+out,comp);
	for(int i=1;i<out;i++)
	printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mkp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 1000005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
struct operation
{
	int id;ll up,down;
}oper[MAXN];
struct cmp
{
	inline bool operator()(const operation& a,const operation& b)
	{
		return a.up*b.down>b.up*a.down;
	}
};
int n,m,K,cnt;
ll a[MAXN],mval[MAXN];int mtag[MAXN],type[MAXN];
vector<pair<ll,int> > ope[MAXN];
int ans[MAXN];
inline bool comp(int a,int b)
{
	return type[a]<type[b];
}
int main()
{
	n=read(),m=read(),K=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<=m;i++)
	{
		type[i]=read();int x=read(),y=read();
		if(type[i]==1)
		{
			if(mval[x]<y)
			mval[x]=y,mtag[x]=i;
		}
		if(type[i]==2)
		ope[x].pb(mkp(y,i));
		if(type[i]==3)
		oper[++cnt].id=i,oper[cnt].up=y,oper[cnt].down=1;
	}
	for(int i=1;i<=n;i++)
	if(mtag[i])
	ope[i].pb(mkp(mval[i]-a[i],mtag[i]));
	for(int i=1;i<=n;i++)
	{
		sort(ope[i].begin(),ope[i].end());
		for(int j=0;j<ope[i].size();j++)
		oper[++cnt].id=ope[i][j].sc,oper[cnt].down=a[i],oper[cnt].up=a[i]+ope[i][j].fr,a[i]+=ope[i][j].fr;
	}
	sort(oper+1,oper+cnt+1,cmp());
	int out=1;
	for(;out<=K;out++)
	{
		if(oper[out].up>oper[out].down)
		ans[out]=oper[out].id;
		else
		break;
	}
	printf("%d\n",out-1);
	sort(ans+1,ans+out,comp);
	for(int i=1;i<out;i++)
	printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define res register int
#define ll long long
#define pb push_back
#define mkp make_pair
#define fr first
#define sc second
#define INF 1000000007
#define gc getchar()
#define MAXN 1000005
#define lc pos<<1
#define rc pos<<1|1
using namespace std;

inline int read()
{
    int ch=gc,f=0;
    int x=0;
    while(ch<'0'||ch>'9')
    {
        f|=ch=='-';
        ch=gc;
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=gc;
    }
    return f?-x:x;
}
struct operation
{
	int id;ll up,down;
}oper[MAXN];
struct cmp
{
	inline bool operator()(const operation& a,const operation& b)
	{
		return a.up/(double)a.down>b.up/(double)b.down;
	}
};
int n,m,K,cnt;
ll a[MAXN],mval[MAXN];int mtag[MAXN],type[MAXN];
vector<pair<ll,int> > ope[MAXN];
int ans[MAXN];
inline bool comp(int a,int b)
{
	return type[a]<type[b];
}
int main()
{
	n=read(),m=read(),K=read();
	for(int i=1;i<=n;i++)
	a[i]=read();
	for(int i=1;i<=m;i++)
	{
		type[i]=read();int x=read(),y=read();
		if(type[i]==1)
		{
			if(mval[x]<y)
			mval[x]=y,mtag[x]=i;
		}
		if(type[i]==2)
		ope[x].pb(mkp(y,i));
		if(type[i]==3)
		oper[++cnt].id=i,oper[cnt].up=y,oper[cnt].down=1;
	}
	for(int i=1;i<=n;i++)
	if(mtag[i])
	ope[i].pb(mkp(mval[i]-a[i],mtag[i]));
	for(int i=1;i<=n;i++)
	{
		sort(ope[i].begin(),ope[i].end());
		reverse(ope[i].begin(),ope[i].end());
		for(int j=0;j<ope[i].size();j++)
		oper[++cnt].id=ope[i][j].sc,oper[cnt].down=a[i],oper[cnt].up=a[i]+ope[i][j].fr,a[i]+=ope[i][j].fr;
	}
	sort(oper+1,oper+cnt+1,cmp());
	int out=1;
	for(;out<=K;out++)
	{
		if(oper[out].up>oper[out].down)
		ans[out]=oper[out].id;
		else
		break;
	}
	printf("%d\n",out-1);
	sort(ans+1,ans+out,comp);
	for(int i=1;i<out;i++)
	printf("%d ",ans[i]);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pr;

struct Frac {
  ll x,y;
  int id;
  Frac() {}
  Frac(ll a,ll b,int c):x(a),y(b),id(c) {}
  bool operator < (const Frac & b) const {
  	if ((ldb)x*b.y!=(ldb)y*b.x) return (ldb)x*b.y>(ldb)y*b.x;
  	return id<b.id;
  }
};

vector <pr> vt[100005],ans;
Frac a[100005];

int num[100005],kind[100005];
pr maxn[100005];

int main() {
  int k,n,m;
  scanf("%d%d%d",&k,&n,&m);
  for(int i=1;i<=k;i++) scanf("%d",&num[i]);
  int cnt=0;
  for(int i=1;i<=n;i++) {
  	int x,y,z;
  	scanf("%d%d%d",&z,&x,&y);
  	if (z==1) maxn[x]=max(maxn[x],pr(y,i));
  	else if (z==2) vt[x].push_back(pr(y,i));
  	else a[++cnt]=Frac(y,1,i);
  	kind[i]=z;
  }
  for(int i=1;i<=k;i++) {
    if (maxn[i].FR>num[i]) vt[i].push_back(pr(maxn[i].FR-num[i],maxn[i].SE));
    sort(vt[i].begin(),vt[i].end());
    reverse(vt[i].begin(),vt[i].end());
    ll s=num[i];
    for(int j=0;j<vt[i].size();j++) {
    	a[++cnt]=Frac(s+vt[i][j].FR,s,vt[i][j].SE);
    	s+=vt[i][j].FR;
	}
  }
  sort(a+1,a+cnt+1);
  for(int i=1;i<=min(cnt,m);i++) {
  	int x=a[i].id;
  	ans.push_back(pr(kind[x],x));
  }
  sort(ans.begin(),ans.end());
  printf("%d\n",(int)ans.size());
  for(int i=0;i<ans.size();i++) printf("%d ",ans[i].SE);
  printf("\n");
  return 0;
}


#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pr;

struct Frac {
  ll x,y;
  int id;
  Frac() {}
  Frac(ll a,ll b,int c):x(a),y(b),id(c) {}
  bool operator < (const Frac & b) const {
  	if ((x-y)*b.y!=y*(b.x-b.y)) return (x-y)*b.y>y*(b.x-b.y);
  	return id<b.id;
  }
};

vector <pr> vt[100005],ans;
Frac a[100005];

int num[100005],kind[100005];
pr maxn[100005];

int main() {
  int k,n,m;
  scanf("%d%d%d",&k,&n,&m);
  for(int i=1;i<=k;i++) scanf("%d",&num[i]);
  int cnt=0;
  for(int i=1;i<=n;i++) {
  	int x,y,z;
  	scanf("%d%d%d",&z,&x,&y);
  	if (z==1) maxn[x]=max(maxn[x],pr(y,i));
  	else if (z==2) vt[x].push_back(pr(y,i));
  	else a[++cnt]=Frac(y,1,i);
  	kind[i]=z;
  }
  for(int i=1;i<=k;i++) {
    if (maxn[i].FR>num[i]) vt[i].push_back(pr(maxn[i].FR-num[i],maxn[i].SE));
    sort(vt[i].begin(),vt[i].end());
    reverse(vt[i].begin(),vt[i].end());
    ll s=num[i];
    for(int j=0;j<vt[i].size();j++) {
    	a[++cnt]=Frac(s+vt[i][j].FR,s,vt[i][j].SE);
    	s+=vt[i][j].FR;
	}
  }
  sort(a+1,a+cnt+1);
  for(int i=1;i<=min(cnt,m);i++) {
  	int x=a[i].id;
  	ans.push_back(pr(kind[x],x));
  }
  sort(ans.begin(),ans.end());
  printf("%d\n",(int)ans.size());
  for(int i=0;i<ans.size();i++) printf("%d ",ans[i].SE);
  printf("\n");
  return 0;
}


#include <bits/stdc++.h>
#define FR first
#define SE second

using namespace std;

typedef long long ll;
typedef pair<int,int> pr;

struct Frac {
  ll x,y;
  int id;
  Frac() {}
  Frac(ll a,ll b,int c):x(a),y(b),id(c) {}
  bool operator < (const Frac & b) const {
  	if (x*b.y!=y*b.x) return x*b.y>y*b.x;
  	return id<b.id;
  }
};

vector <pr> vt[100005],ans;
Frac a[100005];

int num[100005],kind[100005];
pr maxn[100005];

int main() {
  int k,n,m;
  scanf("%d%d%d",&k,&n,&m);
  for(int i=1;i<=k;i++) scanf("%d",&num[i]);
  int cnt=0;
  for(int i=1;i<=n;i++) {
  	int x,y,z;
  	scanf("%d%d%d",&z,&x,&y);
  	if (z==1) maxn[x]=max(maxn[x],pr(y,i));
  	else if (z==2) vt[x].push_back(pr(y,i));
  	else a[++cnt]=Frac(y,1,i);
  	kind[i]=z;
  }
  for(int i=1;i<=k;i++) {
    if (maxn[i].FR>num[i]) vt[i].push_back(pr(maxn[i].FR-num[i],maxn[i].SE));
    sort(vt[i].begin(),vt[i].end());
    reverse(vt[i].begin(),vt[i].end());
    ll s=num[i];
    for(int j=0;j<vt[i].size();j++) {
    	a[++cnt]=Frac(s+vt[i][j].FR,s,vt[i][j].SE);
    	s+=vt[i][j].FR;
	}
  }
  sort(a+1,a+cnt+1);
  for(int i=1;i<=min(cnt,m);i++) {
  	int x=a[i].id;
  	ans.push_back(pr(kind[x],x));
  }
  sort(ans.begin(),ans.end());
  printf("%d\n",(int)ans.size());
  for(int i=0;i<ans.size();i++) printf("%d ",ans[i].SE);
  printf("\n");
  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define N 100005
#define ll long long
using namespace std;
int n,m,k,top1,top2,top3;
int mx[N],id[N];
ll a[N];
struct pl{int op,id,it;ll a,b;}s[N],t1[N],t2[N],t3[N];
bool cmp(const pl &A,const pl &B){return A.a>B.a;}
bool cmp1(const pl &A,const pl &B){return (double)A.a*B.b>(double)A.b*B.a;}
bool cmp2(const pl &A,const pl &B){return A.op<B.op;}
int gcd(ll a,ll b){
	while(b!=0){
		ll t=b;b=a%b;a=t;
	}
	return a;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d%lld",&s[i].op,&s[i].id,&s[i].a);
		if(s[i].op==1){
			top1++;t1[top1].a=s[i].a;t1[top1].id=s[i].id;t1[top1].it=i;
		}
		if(s[i].op==2){
			top2++;t2[top2].a=s[i].a;t2[top2].id=s[i].id;t2[top2].op=2;t2[top2].it=i;
		}
		if(s[i].op==3){
			top3++;t3[top3].a=s[i].a;t3[top3].b=1;t3[top3].id=s[i].id;t3[top3].op=3;t3[top3].it=i;
		}
	}
	for(int i=1;i<=top1;i++){
		if(t1[i].a>mx[t1[i].id]) mx[t1[i].id]=t1[i].a,id[t1[i].id]=t1[i].it;
	}
	for(int i=1;i<=n;i++){
		if(id[i]!=0&&mx[i]>a[i]){
			top2++;t2[top2].a=mx[i]-a[i];t2[top2].it=id[i];t2[top2].op=1;t2[top2].id=i;
		}
	}
	sort(t2+1,t2+1+top2,cmp);
//	for(int i=1;i<=top2;i++) cout<<t2[i].it<<" ";cout<<endl;
	for(int i=1;i<=top2;i++){
		top3++;t3[top3].op=t2[i].op;t3[top3].it=t2[i].it;
		ll l1=a[t2[i].id],l2=a[t2[i].id]+t2[i].a;a[t2[i].id]+=t2[i].a;
		t3[top3].a=l2;t3[top3].b=l1;ll tmp=gcd(t3[top3].a,t3[top3].b);
		t3[top3].a/=tmp;t3[top3].b/=tmp;
	}
	sort(t3+1,t3+1+top3,cmp1);int si=min(k,top3);sort(t3+1,t3+1+si,cmp2);
	printf("%d\n",si);if(si==0) return 0;
	for(int i=1;i<si;i++) printf("%d ",t3[i].it);
	printf("%d\n",t3[si].it);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define N 100005
#define ll long long
using namespace std;
int n,m,k,top1,top2,top3;
int a[N],mx[N],id[N];
struct pl{int op,a,b,id,it;}s[N],t1[N],t2[N],t3[N];
bool cmp(const pl &A,const pl &B){return A.a>B.a;}
bool cmp1(const pl &A,const pl &B){return (ll)A.a*B.b>(ll)A.b*B.a;}
bool cmp2(const pl &A,const pl &B){return A.op<B.op;}
int gcd(int a,int b){
	while(b!=0){
		int t=b;b=a%b;a=t;
	}
	return a;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&s[i].op,&s[i].id,&s[i].a);
		if(s[i].op==1){
			top1++;t1[top1].a=s[i].a;t1[top1].id=s[i].id;t1[top1].it=i;
		}
		if(s[i].op==2){
			top2++;t2[top2].a=s[i].a;t2[top2].id=s[i].id;t2[top2].op=2;t2[top2].it=i;
		}
		if(s[i].op==3){
			top3++;t3[top3].a=s[i].a;t3[top3].b=1;t3[top3].id=s[i].id;t3[top3].op=3;t3[top3].it=i;
		}
	}
	for(int i=1;i<=top1;i++){
		if(t1[i].a>mx[t1[i].id]) mx[t1[i].id]=t1[i].a,id[t1[i].id]=t1[i].it;
	}
	for(int i=1;i<=n;i++){
		if(id[i]!=0&&mx[i]>a[i]){
			top2++;t2[top2].a=mx[i]-a[i];t2[top2].it=id[i];t2[top2].op=1;t2[top2].id=i;
		}
	}
	sort(t2+1,t2+1+top2,cmp);
//	for(int i=1;i<=top2;i++) cout<<t2[i].it<<" ";cout<<endl;
	for(int i=1;i<=top2;i++){
		top3++;t3[top3].op=t2[i].op;t3[top3].it=t2[i].it;
		int l1=a[t2[i].id],l2=a[t2[i].id]+t2[i].a;a[t2[i].id]+=t2[i].a;
		t3[top3].a=l2;t3[top3].b=l1;int tmp=gcd(t3[top3].a,t3[top3].b);
		t3[top3].a/=tmp;t3[top3].b/=tmp;
	}
	sort(t3+1,t3+1+top3,cmp1);int si=min(k,top3);sort(t3+1,t3+1+si,cmp2);
	printf("%d\n",si);
	for(int i=1;i<si;i++) printf("%d ",t3[i].it);
	printf("%d\n",t3[si].it);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define N 100005
#define ll long long
using namespace std;
int n,m,k,top1,top2,top3;
int a[N],mx[N],id[N];
struct pl{int op,a,b,id,it;}s[N],t1[N],t2[N],t3[N];
bool cmp(const pl &A,const pl &B){return A.a>B.a;}
bool cmp1(const pl &A,const pl &B){return (ll)A.a*B.b>(ll)A.b*B.a;}
bool cmp2(const pl &A,const pl &B){return A.op<B.op;}
int gcd(int a,int b){
	while(b!=0){
		int t=b;b=a%b;a=t;
	}
	return a;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d%d",&s[i].op,&s[i].id,&s[i].a);
		if(s[i].op==1){
			top1++;t1[top1].a=s[i].a;t1[top1].id=s[i].id;t1[top1].it=i;
		}
		if(s[i].op==2){
			top2++;t2[top2].a=s[i].a;t2[top2].id=s[i].id;t2[top2].op=2;t2[top2].it=i;
		}
		if(s[i].op==3){
			top3++;t3[top3].a=s[i].a;t3[top3].b=1;t3[top3].id=s[i].id;t3[top3].op=3;t3[top3].it=i;
		}
	}
	for(int i=1;i<=top1;i++){
		if(t1[i].a>mx[t1[i].id]) mx[t1[i].id]=t1[i].a,id[t1[i].id]=t1[i].it;
	}
	for(int i=1;i<=n;i++){
		if(id[i]!=0&&mx[i]>a[i]){
			top2++;t2[top2].a=mx[i]-a[i];t2[top2].it=id[i];t2[top2].op=1;t2[top2].id=i;
		}
	}
	sort(t2+1,t2+1+top2,cmp);
//	for(int i=1;i<=top2;i++) cout<<t2[i].it<<" ";cout<<endl;
	for(int i=1;i<=top2;i++){
		top3++;t3[top3].op=t2[i].op;t3[top3].it=t2[i].it;
		int l1=a[t2[i].id],l2=a[t2[i].id]+t2[i].a;a[t2[i].id]+=t2[i].a;
		t3[top3].a=l2;t3[top3].b=l1;int tmp=gcd(t3[top3].a,t3[top3].b);
		t3[top3].a/=tmp;t3[top3].b/=tmp;
	}
	sort(t3+1,t3+1+top3,cmp1);int si=min(k,top3);sort(t3+1,t3+1+si,cmp2);
	printf("%d\n",si);if(si==0) return 0;
	for(int i=1;i<si;i++) printf("%d ",t3[i].it);
	printf("%d\n",t3[si].it);
	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#define N 100005
#define ll long long
using namespace std;
int n,m,k,top1,top2,top3;
int mx[N],id[N];
ll a[N];
struct pl{int op,id,it;ll a,b;}s[N],t1[N],t2[N],t3[N];
bool cmp(const pl &A,const pl &B){return A.a>B.a;}
bool cmp1(const pl &A,const pl &B){return (double)A.a*B.b>(double)A.b*B.a;}
bool cmp2(const pl &A,const pl &B){return A.op<B.op;}
int gcd(ll a,ll b){
	while(b!=0){
		int t=b;b=a%b;a=t;
	}
	return a;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=m;i++){
		scanf("%d%d%lld",&s[i].op,&s[i].id,&s[i].a);
		if(s[i].op==1){
			top1++;t1[top1].a=s[i].a;t1[top1].id=s[i].id;t1[top1].it=i;
		}
		if(s[i].op==2){
			top2++;t2[top2].a=s[i].a;t2[top2].id=s[i].id;t2[top2].op=2;t2[top2].it=i;
		}
		if(s[i].op==3){
			top3++;t3[top3].a=s[i].a;t3[top3].b=1;t3[top3].id=s[i].id;t3[top3].op=3;t3[top3].it=i;
		}
	}
	for(int i=1;i<=top1;i++){
		if(t1[i].a>mx[t1[i].id]) mx[t1[i].id]=t1[i].a,id[t1[i].id]=t1[i].it;
	}
	for(int i=1;i<=n;i++){
		if(id[i]!=0&&mx[i]>a[i]){
			top2++;t2[top2].a=mx[i]-a[i];t2[top2].it=id[i];t2[top2].op=1;t2[top2].id=i;
		}
	}
	sort(t2+1,t2+1+top2,cmp);
//	for(int i=1;i<=top2;i++) cout<<t2[i].it<<" ";cout<<endl;
	for(int i=1;i<=top2;i++){
		top3++;t3[top3].op=t2[i].op;t3[top3].it=t2[i].it;
		ll l1=a[t2[i].id],l2=a[t2[i].id]+t2[i].a;a[t2[i].id]+=t2[i].a;
		t3[top3].a=l2;t3[top3].b=l1;ll tmp=gcd(t3[top3].a,t3[top3].b);
		t3[top3].a/=tmp;t3[top3].b/=tmp;
	}
	sort(t3+1,t3+1+top3,cmp1);int si=min(k,top3);sort(t3+1,t3+1+si,cmp2);
	printf("%d\n",si);if(si==0) return 0;
	for(int i=1;i<si;i++) printf("%d ",t3[i].it);
	printf("%d\n",t3[si].it);
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
int n,m,k,tot;
int a[maxn];
int datt[maxn],dati[maxn],datb[maxn],mx[maxn],mxid[maxn];
vector<pii>vec[maxn];
class Frac{
public:
	ll x,y;
	Frac(ll _x=0,ll _y=1):x(_x),y(_y){}
	bool operator < (const Frac &o)const{
		return x*o.y<o.x*y;
	}
};
pair<Frac,int>val[maxn];
vector<int>ans[4];

int main(){
	scanf("%d%d%d",&k,&n,&m);
	REP(i,k)scanf("%d",&a[i]);
	REP(i,n){
		scanf("%d%d%d",&datt[i],&dati[i],&datb[i]);
		if(datt[i]==1){
			if(datb[i]>mx[dati[i]]){
				mx[dati[i]]=datb[i];
				mxid[dati[i]]=i;
			}
		}
		else if(datt[i]==2)vec[dati[i]].pb(mp(datb[i],i));
		else val[++tot]=mp(Frac(datb[i],1),i);
	}
	REP(i,k){
		if(mx[i]>a[i])vec[i].pb(mp(mx[i]-a[i],mxid[i]));
		sort(vec[i].begin(),vec[i].end());
		ll now=a[i];
		for(int j=int(vec[i].size())-1;j>=0;j--){
			now+=vec[i][j].fst;
			val[++tot]=mp(Frac(now,now-vec[i][j].fst),vec[i][j].snd);
		}
	}
	sort(val+1,val+1+tot);
	for(int i=tot;i>=max(1,tot-m+1);i--){
		ans[datt[val[i].snd]].pb(val[i].snd);
	}
	printf("%d\n",int(ans[1].size())+int(ans[2].size())+int(ans[3].size()));
	REP(t,3)rep(i,int(ans[t].size()))printf("%d ",ans[t][i]);
	puts("");
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int maxn=100005;
int n,m,k,tot;
int a[maxn];
int datt[maxn],dati[maxn],datb[maxn],mx[maxn],mxid[maxn];
vector<pii>vec[maxn];
class Frac{
public:
	ll x,y;
	Frac(ll _x=0,ll _y=1):x(_x),y(_y){}
	bool operator < (const Frac &o)const{
		return ldb(x)*ldb(o.y)<ldb(o.x)*ldb(y);
	}
};
pair<Frac,int>val[maxn];
vector<int>ans[4];

int main(){
	scanf("%d%d%d",&k,&n,&m);
	REP(i,k)scanf("%d",&a[i]);
	REP(i,n){
		scanf("%d%d%d",&datt[i],&dati[i],&datb[i]);
		if(datt[i]==1){
			if(datb[i]>mx[dati[i]]){
				mx[dati[i]]=datb[i];
				mxid[dati[i]]=i;
			}
		}
		else if(datt[i]==2)vec[dati[i]].pb(mp(datb[i],i));
		else val[++tot]=mp(Frac(datb[i],1),i);
	}
	REP(i,k){
		if(mx[i]>a[i])vec[i].pb(mp(mx[i]-a[i],mxid[i]));
		sort(vec[i].begin(),vec[i].end());
		ll now=a[i];
		for(int j=int(vec[i].size())-1;j>=0;j--){
			now+=vec[i][j].fst;
			val[++tot]=mp(Frac(now,now-vec[i][j].fst),vec[i][j].snd);
		}
	}
	sort(val+1,val+1+tot);
	for(int i=tot;i>=max(1,tot-m+1);i--){
		ans[datt[val[i].snd]].pb(val[i].snd);
	}
	printf("%d\n",int(ans[1].size())+int(ans[2].size())+int(ans[3].size()));
	REP(t,3)rep(i,int(ans[t].size()))printf("%d ",ans[t][i]);
	puts("");
	return 0;
}


#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
#define ll long long
#define P pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define N 100100
using namespace std;

ll n,m,k,num[N],cz[N];
P chg[N];
inline ll gcd(ll u,ll v)
{
	for(;u&&v&&u!=v;)
	{
		swap(u,v);
		u%=v;
	}
	return max(u,v);
}
struct Fs
{
	ll fz,fm,id;
	void yf()
	{
		ll g=gcd(fz,fm);
		fz/=g;
		fm/=g;
	}
	bool operator < (const Fs &u) const
	{
		return fz*u.fm<fm*u.fz;
	}
}tmp;
vector<P>add[N];
vector<ll>ans;
priority_queue<Fs>pq;

inline bool cmp(P u,P v){return u>v;}
inline bool cmp2(ll u,ll v){return cz[u]<cz[v];}

int main()
{
	ll i,j,o,p,q;
	cin>>n>>m>>k;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&num[i]);
	}
	for(i=1;i<=m;i++)
	{
		scanf("%lld%lld%lld",&o,&p,&q);
		cz[i]=o;
		if(o==1)
		{
			chg[p]=max(chg[p],mp(q-num[p],i));
		}
		else if(o==2)
		{
			add[p].push_back(mp(q,i));
		}
		else
		{
			tmp.fz=q-1;
			tmp.fm=1;
			tmp.id=i;
			pq.push(tmp);
		}
	}
//	for(i=1;i<=n;i++) cout<<chg[i].fi<<" ";return 0;
	for(i=1;i<=n;i++)
	{
		if(chg[i].fi) add[i].push_back(chg[i]);
		sort(add[i].begin(),add[i].end(),cmp);
//		cout<<" "<<i<<":";for(j=0;j<add[i].size();j++) cout<<add[i][j].fi<<' ';puts("");
		o=num[i];
		for(j=0;j<add[i].size();j++)
		{
			tmp.fz=add[i][j].fi;
			tmp.fm=o;
			tmp.id=add[i][j].se;
			tmp.yf();
			pq.push(tmp);
			o+=add[i][j].fi;
		}
	}
//	for(;!pq.empty();pq.pop()) cout<<pq.top().fz<<" "<<pq.top().fm<<endl;return 0;
	for(i=1;i<=k&&!pq.empty();i++)
	{
		ans.push_back(pq.top().id);
		pq.pop();
	}
	cout<<ans.size()<<endl;
	sort(ans.begin(),ans.end(),cmp2);
	for(i=0;i<ans.size();i++) printf("%lld ",ans[i]);
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define N 100010
#define ll long long
using namespace std;
struct node{
	double x;
	int id;
	node(double X=0.0,int ID=0):x(X),id(ID){}
	bool operator <(const node a)const{return x>a.x;}
}c[N];
int a[N],opt[N];
vector<node>ad[N],mul;
int ans[N];
bool cmp(int x,int y){return opt[x]<opt[y];}
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d%d%d",&opt[i],&x,&y);
		if(opt[i]==1) c[x]=min(c[x],node(y,i));
		if(opt[i]==2) ad[x].push_back(node(y,i));
		if(opt[i]==3) mul.push_back(node(y,i));
	}
	for(int i=1;i<=n;i++)
	if(c[i].x>a[i]) ad[i].push_back(node(c[i].x-a[i],c[i].id));
	for(int i=1;i<=n;i++)
	{
		sort(ad[i].begin(),ad[i].end());
		ll w=a[i];
		for(auto v:ad[i]) mul.push_back(node((w+v.x)/w,v.id)),w+=v.x;
	}
	sort(mul.begin(),mul.end());
	printf("%d\n",k=min(k,(int)mul.size()));
	for(int i=0;i<k;i++) ans[i]=mul[i].id;
	sort(ans,ans+k,cmp);
	for(int i=0;i<k;i++) printf("%d ",ans[i]);
	return 0;
}


// written by newbiechd
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

// DELETE the debugging information!
#define debug(x) std::cerr << #x << " = " << (x) << std::endl

int read() {
  int f = 0;
  char ch;
  while (!isdigit(ch = getchar()));
  do f = 10 * f + (ch ^ '0');
  while (isdigit(ch = getchar()));
  return f;
}

const int N_MAX = 100003;
int a[N_MAX];
std::pair<int, int> assign[N_MAX];

struct Add {
  int val, id, type;
  Add() {}
  Add(const int &val, const int &id, const int &type) :
    val(val), id(id), type(type) {}
  friend bool operator<(const Add &lhs, const Add &rhs) {
    return lhs.val > rhs.val;
  }
};
std::vector<Add> add[N_MAX];

struct Mul {
  double val;
  int id, type;
  Mul() {}
  Mul(const double &val, const int &id, const int &type) :
    val(val), id(id), type(type) {}
  friend bool operator<(const Mul &lhs, const Mul &rhs) {
    return lhs.val > rhs.val;
  }
};
std::vector<Mul> mul;
bool cmp(const Mul &lhs, const Mul &rhs) {
  return lhs.type < rhs.type;
}

int main() {
#ifndef ONLINE_JUDGE
  freopen("a.in", "r", stdin);
  // freopen("a.out", "w", stdout);
#endif

  int k = read(), n = read(), m = read();
  for (int i = 1; i <= k; ++i)
    a[i] = read();
  for (int i = 1; i <= n; ++i) {
    int t = read(), id = read(), b = read();
    switch (t) {
    case 1:
      assign[id] = std::max(std::make_pair(b, i), assign[id]);
      break;
    case 2:
      add[id].push_back(Add(b, i, 2));
      break;
    case 3:
      mul.push_back(Mul(b, i, 3));
      break;
    }
  }

  for (int i = 1; i <= k; ++i) {
    if (assign[i].first > a[i])
      add[i].push_back(Add(assign[i].first - a[i], assign[i].second, 1));
    std::sort(add[i].begin(), add[i].end());
    double now = a[i];
    for (Add x : add[i]) {
      mul.push_back(Mul(x.val / now + 1, x.id, x.type));
      now += x.val;
    }
  }
  std::sort(mul.begin(), mul.end());
  if ((int)mul.size() > m)
    mul.resize(m);
  std::sort(mul.begin(), mul.end(), cmp);
  printf("%d\n", (int)mul.size());
  for (Mul x : mul) {
    printf("%d ", x.id);
    if (!--m)
      break;
  }
  return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int k,n,m,sa[100005],t[100005],id[100005],b[100005];
ll a[100005],v[100005];
bool flag[100005];
bool cmp1(int x,int y)
{
	if(id[x]!=id[y])return id[x]<id[y];
	if(t[x]!=t[y])return t[x]<t[y];
	return b[x]>b[y];
}
bool cmp2(int x,int y)
{
	if(v[x]==-1)return 0;
	if(v[y]==-1)return 1;
	return b[x]*v[y]>b[y]*v[x];
}
int main()
{
	scanf("%d%d%d",&k,&n,&m);
	for(int i=1;i<=k;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t[i],&id[i],&b[i]);
		sa[i]=i;
	}
	sort(sa+1,sa+n+1,cmp1);
	for(int ii=1;ii<=n;ii++)
	{
		int i=sa[ii];
		if(t[i]==1)
		{
			if(b[i]<a[id[i]])v[i]=-1;
			else
			{
				v[i]=a[id[i]];
				a[id[i]]=b[i];
				b[i]-=(int)v[i];
			}
		}
		if(t[i]==2)
		{
			v[i]=a[id[i]];
			a[id[i]]+=b[i];
		}
		if(t[i]==3)v[i]=1,b[i]--;
	}
	sort(sa+1,sa+n+1,cmp2);
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		if(v[sa[i]]!=-1)
		{
			flag[sa[i]]=1;
			ans++;
		}
	}
	printf("%d\n",ans);
	sort(sa+1,sa+n+1,cmp1);
	for(int i=1;i<=n;i++)
	{
		if(flag[sa[i]])
		  printf("%d ",sa[i]);
	}
	printf("\n");
	return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
int k,n,m,sa[100005],t[100005],id[100005],b[100005];
ll a[100005],v[100005];
bool flag[100005],c[100005];
bool cmp1(int x,int y)
{
	if(id[x]!=id[y])return id[x]<id[y];
	if(t[x]!=t[y])return t[x]<t[y];
	return b[x]>b[y];
}
bool cmp2(int x,int y)
{
	if(v[x]==-1)return 0;
	if(v[y]==-1)return 1;
	return b[x]*v[y]>b[y]*v[x];
}
int main()
{
	scanf("%d%d%d",&k,&n,&m);
	for(int i=1;i<=k;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&t[i],&id[i],&b[i]);
		sa[i]=i;
	}
	sort(sa+1,sa+n+1,cmp1);
	for(int ii=1;ii<=n;ii++)
	{
		int i=sa[ii];
		if(t[i]==1)
		{
			if(b[i]>a[id[i]]&&!flag[id[i]])
			{
				b[i]-=(int)a[id[i]];
				c[i]=1;
				t[i]=2;
				flag[id[i]]=1;
			}
		}
	}
	sort(sa+1,sa+n+1,cmp1);
	memset(flag,0,sizeof(flag));
	for(int ii=1;ii<=n;ii++)
	{
		int i=sa[ii];
		if(t[i]==1)v[i]=-1;
		if(t[i]==2)
		{
			v[i]=a[id[i]];
			a[id[i]]+=b[i];
		}
		if(t[i]==3)v[i]=1,b[i]--;
	}
	sort(sa+1,sa+n+1,cmp2);
	int ans=0;
	for(int i=1;i<=m;i++)
	{
		if(v[sa[i]]!=-1)
		{
			flag[sa[i]]=1;
			ans++;
		}
	}
	printf("%d\n",ans);
	for(int i=1;i<=n;i++)
	  if(c[i])t[i]=1;
	sort(sa+1,sa+n+1,cmp1);
	for(int i=1;i<=n;i++)
	{
		if(flag[sa[i]])
		  printf("%d ",sa[i]);
	}
	printf("\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline void myassert(bool a,string s){ if(!a)cerr<<s<<endl,exit(0);}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1e5+20;

int k,n,m;
ll a[maxn];
pair<int,int> mx[maxn];

int OP[maxn];

struct Quest {
	int op,id,b,RID;
};
Quest qu[maxn];
int qtot;

struct node {
	double prod;
	int id,op,RID;
	node(double _prod=0,int _id=0,int _op=0,int _RID=0){ prod=_prod; id=_id; op=_op; RID=_RID;}
};
inline bool operator < (node a,node b){ return a.prod==b.prod?a.op<b.op:a.prod<b.prod;}

priority_queue<node>Qall;
vector<node>Q[maxn];

inline void init()
{
	k=read();n=read();m=read();
	REP(i,1,k)a[i]=read();
	REP(i,1,n)
	{
		int op=read(),id=read(),b=read();
		OP[i]=op;
		if(op==2 || (op==3 && b>1))qu[++qtot]=(Quest){op,id,b,i};
		if(op==1)chkmax(mx[id],mkr(b,i));
	}
	REP(i,1,k)if(mx[i].fi>a[i])qu[++qtot]=(Quest){2,i,mx[i].fi-a[i],mx[i].se};
	REP(i,1,qtot)
	{
		int id=qu[i].id;
		if(qu[i].op==3)Qall.push(node(qu[i].b,qu[i].id,qu[i].op,qu[i].RID));
		else if(qu[i].op==2)Q[qu[i].id].push_back(node(qu[i].b,id,qu[i].op,qu[i].RID));
	}
	REP(i,1,k)sort(Q[i].begin(),Q[i].end());

	REP(i,1,k)if(!Q[i].empty())
	{
		node x=Q[i].back();
		Qall.push(node(1+x.prod/a[i],x.id,x.op,x.RID));
	}
}

vector<int>ans;

inline void doing()
{
	while(m-- && !Qall.empty())
	{
		node x=Qall.top(); Qall.pop();
		ans.push_back(x.RID);
		if(x.op==2)
		{
			int id=x.id;
			a[id]+=(int)Q[id].back().prod;
			Q[id].pop_back();
			node x=Q[id].back();
			if(!Q[id].empty())Qall.push(node(1+x.prod/a[id],x.id,x.op,x.RID));
		}
	}
	sort(ans.begin(),ans.end(),[](int a,int b){ return OP[a]<OP[b];});
	printf("%d\n",SZ(ans));
	REP(i,0,SZ(ans)-1)printf("%d ",ans[i]);
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("CF521D.in","r",stdin);
	freopen("CF521D.out","w",stdout);
#endif
	init();
	doing();
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int MK = 100005, MN = 100005;

int K, N, M;
LL A[MK], B[MK];
int typ[MN], pos[MN];
LL val[MN], denom[MN];
std::vector<int> Vadd[MN];
int padd[MN], cadd;
int pmul[MN], cmul;
int Ans[MN], Cnt;

int main() {
	scanf("%d%d%d", &K, &N, &M);
	for (int i = 1; i <= K; ++i) scanf("%lld", &A[i]), B[i] = A[i];
	for (int i = 1; i <= N; ++i) {
		scanf("%d%d%lld", &typ[i], &pos[i], &val[i]);
		if (typ[i] == 1) B[pos[i]] = std::max(B[pos[i]], val[i]);
	}
	for (int i = 1; i <= N; ++i) {
		if (typ[i] != 3) {
			if (typ[i] == 1) {
				if (val[i] != B[pos[i]]) continue;
				val[i] -= A[pos[i]];
			}
			padd[++cadd] = i;
			Vadd[pos[i]].push_back(i);
		} else if (val[i] > 1) pmul[++cmul] = i;
	}
	typ[N + 1] = 2, pos[N + 1] = 0, val[N + 1] = 0, denom[N + 1] = 1;
	typ[N + 2] = 3, pos[N + 2] = 0, val[N + 2] = 1;
	while (cadd < M) padd[++cadd] = N + 1;
	while (cmul < M) pmul[++cmul] = N + 2;
	auto cmp = [](int i, int j) { return val[i] > val[j]; };
	std::sort(pmul + 1, pmul + cmul + 1, cmp);
	for (int i = 1; i <= K; ++i) {
		std::sort(Vadd[i].begin(), Vadd[i].end(), cmp);
		LL v = A[i];
		for (auto x : Vadd[i]) denom[x] = v, v += val[x];
	}
	std::sort(padd + 1, padd + cadd + 1, [](int i, int j) { return val[i] * denom[j] > val[j] * denom[i]; });
	int j2 = M, j1 = 1;
	while (j2 && val[pmul[j2]] * denom[padd[j1]] < denom[padd[j1]] + val[padd[j1]]) ++j1, --j2;
	--j1;
	for (int i = 1; i <= j1; ++i) if (padd[i] <= N) Ans[++Cnt] = padd[i];
	for (int i = 1; i <= j2; ++i) if (pmul[i] <= N) Ans[++Cnt] = pmul[i];
	std::sort(Ans + 1, Ans + Cnt + 1, [](int i, int j) { return typ[i] < typ[j]; });
	printf("%d\n", Cnt);
	for (int i = 1; i <= Cnt; ++i) printf("%d%c", Ans[i], " \n"[i == Cnt]);
	return 0;
}


#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int MK = 100005, MN = 100005;

int K, N, M;
LL A[MK], B[MK];
int typ[MN + MN], pos[MN];
LL val[MN], denom[MN];
std::vector<int> Vadd[MN];
int padd[MN], cadd;
int pmul[MN], cmul;
int Ans[MN], Cnt;

int main() {
	scanf("%d%d%d", &K, &N, &M);
	for (int i = 1; i <= K; ++i) scanf("%lld", &A[i]), B[i] = A[i];
	for (int i = 1; i <= N; ++i) {
		scanf("%d%d%lld", &typ[i], &pos[i], &val[i]);
		if (typ[i] == 1) B[pos[i]] = std::max(B[pos[i]], val[i]);
	}
	for (int i = 1; i <= N; ++i) {
		if (typ[i] != 3) {
			if (typ[i] == 1) {
				if (val[i] != B[pos[i]]) continue;
				val[i] -= A[pos[i]];
			}
			padd[++cadd] = i;
			Vadd[pos[i]].push_back(i);
		} else if (val[i] > 1) pmul[++cmul] = i;
	}
	typ[N + 1] = 2, pos[N + 1] = 0, val[N + 1] = 1, denom[N + 1] = 1;
	typ[N + 2] = 3, pos[N + 2] = 0, val[N + 2] = 1;
	while (cadd < M) padd[++cadd] = N + 1;
	while (cmul < M) pmul[++cmul] = N + 2;
	auto cmp = [](int i, int j) { return val[i] > val[j]; };
	std::sort(pmul + 1, pmul + cmul + 1, cmp);
	for (int i = 1; i <= K; ++i) {
		std::sort(Vadd[i].begin(), Vadd[i].end(), cmp);
		LL v = A[i];
		for (auto x : Vadd[i]) denom[x] = v, v = val[x] += v;
	}
	std::sort(padd + 1, padd + cadd + 1, [](int i, int j) { return val[i] * denom[j] > val[j] * denom[i]; });
	int j2 = M, j1 = 1;
	while (j2 && val[pmul[j2]] * denom[padd[j1]] < val[padd[j1]]) ++j1, --j2;
	--j1;
	for (int i = 1; i <= j1; ++i) if (padd[i] <= N) Ans[++Cnt] = padd[i];
	for (int i = 1; i <= j2; ++i) if (pmul[i] <= N) Ans[++Cnt] = pmul[i];
	std::sort(Ans + 1, Ans + Cnt + 1, [](int i, int j) { return typ[i] < typ[j]; });
	printf("%d\n", Cnt);
	for (int i = 1; i <= Cnt; ++i) printf("%d%c", Ans[i], " \n"[i == Cnt]);
	return 0;
}


#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>
#include <queue>

#include <algorithm>
#include <numeric>
#include <random>
#include <chrono>
#include <complex>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < static_cast<ll>(n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define endl '\n'
#define f first
#define s second

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

struct upd {
    int t, i;
    ll p, q;
    upd() = default;
    upd(int t, int i, ll p, ll q) : t(t), i(i), p(p), q(q) { }
};

int k, n, m;
ll a[MAXN];
vector<upd> u;
pair<ll, int> asgn[MAXN];
vector< pair<ll, int> > add[MAXN], mul[MAXN];

bool read() {
    if (!(cin >> k >> n >> m))
        return false;

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

    for (int i = 0; i < n; ++i) {
        int t, j;
        ll b;
        cin >> t >> j >> b;
        --j;

        if (t == 1) {
            asgn[j] = max(asgn[j], make_pair(b, i));
        } else if (t == 2) {
            add[j].push_back(make_pair(b, i));
        } else {
            mul[j].push_back(make_pair(b, i));
        }
    }

    return true;
}

void solve() {
    for (int i = 0; i < k; ++i) {
        if (asgn[i].first > a[i])
            add[i].push_back(make_pair(asgn[i].first - a[i], asgn[i].second + n));

        sort(add[i].rbegin(), add[i].rend());
        ll p = a[i], q = a[i];

        for (int j = 0; j < sz(add[i]); ++j) {
            p += add[i][j].first;

            if (p > q) {
                if (add[i][j].second < n)
                    u.push_back(upd(2, add[i][j].second, p, q));
                else
                    u.push_back(upd(1, add[i][j].second - n, p, q));
            }

            q += add[i][j].first;
        }

        for (auto p : mul[i])
            u.push_back(upd(3, p.second, p.first, 1));
    }

    sort(u.begin(), u.end(), [](upd a, upd b) {
        ll p1 = a.p;
        ll q1 = a.q;
        ll p2 = b.p;
        ll q2 = b.q;
        p1 -= q1;
        p2 -= q2;
        return p1 * q2 - p2 * q1 > 0;
    });

    vector<upd> ans;

    for (int i = 0; i < min(sz(u), m); ++i)
        ans.push_back(u[i]);

    sort(ans.begin(), ans.end(), [](upd a, upd b) {
        if (a.t != b.t)
            return a.t < b.t;

        ll p1 = a.p;
        ll q1 = a.q;
        ll p2 = b.p;
        ll q2 = b.q;
        p1 -= q1;
        p2 -= q2;
        return p1 * q2 - p2 * q1 > 0;
    });

    cout << sz(ans) << endl;

    for (auto i : ans)
        cout << i.i + 1 << ' ';

    cout << endl;
}

int32_t main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
    //freopen("/Users/leemonage/CLionProjects/proj/file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


#include<cstdio>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>

using namespace std;

#define bomb exit(1)
#define INF 1061109567
#define LINF 4557430888798830399ll
#define pprint(x) print(x),putchar(' ')
#define fprint(x) print(x),putchar('\n')
#define EE(x); struct edge { int nxt,to,w; }e[M << 1]; int head[N],ecnt = 1;\
	void add(int u,int v,ll w = 0) { e[++ecnt].w = w,e[ecnt].to = v,e[ecnt].nxt = head[u];head[u] = ecnt; }\
	void add_edge(int u,int v,ll w = 0) { add(u,v,w),add(v,u,w * x); }
#define ll long long
const double pi = acos(-1.0);
int mod = 1e9 + 9;
ll Mod(ll x) { return x >= mod ? x - mod : x; }
#define eps 0.000001
#define sqr(x) ((x) * (x))
#define iter iterator
#define fi first
#define se second
#define getchar() (SS == TT && (TT = (SS = BB) + fread(BB,1,1 << 15,stdin),TT == SS) ? EOF : *SS++)
char BB[1 << 15],*SS = BB,*TT = BB;
ll read()
{
	ll x = 0;int f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') f = -1;
	for(;isdigit(ch);ch = getchar()) x = x * 10 + (ch ^ 48);
	return x * f;
}
void print(ll x)
{
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);putchar(x % 10 + '0');
}

const int N = 100010;
struct modify
{
	double x;int id;
	friend bool operator < (modify u,modify v) { return u.x > v.x; }
}c[N];
int n,m,k,a[N],op[N];
vector<modify> add[N],mul;
int ans[N];

int main()
{
	n = read(),m = read(),k = read();
	for(int i = 1;i <= n;i++) a[i] = read();
	for(int i = 1;i <= m;i++)
	{
		op[i] = read();int x = read(),y = read();
		if(op[i] == 1) c[x] = min(c[x],{y,i});
		if(op[i] == 2) add[x].push_back({y,i});
		if(op[i] == 3) mul.push_back({y,i});
	}
	for(int i = 1;i <= n;i++) if(c[i].x > a[i]) add[i].push_back({c[i].x - a[i],c[i].id});
	for(int i = 1;i <= n;i++)
	{
		sort(add[i].begin(),add[i].end());
		ll num = a[i];
		for(auto j:add[i])
			mul.push_back({(num + j.x) / num,j.id}),num += j.x;
	}
	sort(mul.begin(),mul.end());
	fprint(k = min((int)mul.size(),k));
	for(int i = 0;i < k;i++) ans[i] = mul[i].id;
	sort(ans,ans + k,[&](int u,int v) { return op[u] < op[v]; });
	for(int i = 0;i < k;i++) pprint(ans[i]);
}


#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef __float256 ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

static char stdinBuffer[1024];
static char* stdinDataEnd = stdinBuffer + sizeof (stdinBuffer);
static const char* stdinPos = stdinDataEnd;

void readAhead(size_t amount)
{
    size_t remaining = stdinDataEnd - stdinPos;
    if (remaining < amount) {
       memmove(stdinBuffer, stdinPos, remaining);
       size_t sz = fread(stdinBuffer + remaining, 1, sizeof (stdinBuffer) - remaining, stdin);
       stdinPos = stdinBuffer;
       stdinDataEnd = stdinBuffer + remaining + sz;
       if (stdinDataEnd != stdinBuffer + sizeof (stdinBuffer))
         *stdinDataEnd = 0;
    }
}

int readInt()
{
    readAhead(16);

    int x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}

const int maxn=1e5+2;
typedef pair<int,int> pii;
pii bestassign[maxn];
vector<pii> vadd[maxn];
vector<pii> vmul;
ll a[maxn];
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  int k=readInt(),n=readInt(),m=readInt();
  for (int i=0;i<k;i++) {
    a[i]=readInt();
  }
  for (int i=1;i<=n;i++) {
    int t=readInt();
    int skill=readInt()-1;
    int b=readInt();
    if (t==1) {
      chkmax(bestassign[skill], MP(b,-i));
    }
    else if (t==2) vadd[skill].PB(MP(b,i));
    else {
      if (b>1) vmul.PB(MP(b,i));
    }
  }
  for (int skill=0;skill<k;skill++) {
    int gain=bestassign[skill].fst - a[skill];
    if (gain>0) {
      vadd[skill].PB(MP(gain, bestassign[skill].snd));
    }
  }
  sort(vmul.begin(),vmul.end(),greater<pii>());
  vector<pair<ld, int> > valladd;
  for (int skill=0;skill<k;skill++) {
    sort(vadd[skill].begin(),vadd[skill].end(),greater<pii>());
    int sz=vadd[skill].size();
    for (auto &w: vadd[skill]) {
      int add=w.fst,id=w.snd;
      ll numer=a[skill]+add;
      ll denom=a[skill];
      ld frac=((ld)denom)/((ld)numer);
      valladd.PB(MP(frac,id));
      a[skill]+=add;
    }
  }
  sort(valladd.begin(),valladd.end());
  int finaladdsteps=min(m,(int)(valladd.size()));
  {
    int addsteps=finaladdsteps;
    int prevmulsteps=min((int)(vmul.size()), m-addsteps);
    --addsteps;
    for (;addsteps>=0;addsteps--) {
      int mulsteps=min((int)(vmul.size()), m-addsteps);
      ld frac=valladd[addsteps].fst;
      //printf("va:%f\n",(double)valladd[addsteps].fst);
      if (mulsteps!=prevmulsteps) {
        frac=frac*vmul[mulsteps-1].fst;
        //printf("vm:%d\n",vmul[mulsteps-1].fst);
      }
      //printf("addsteps:%d mulsteps:%d frac:%f\n",addsteps,mulsteps,(double)frac);
      if (frac>=1) {
        finaladdsteps=addsteps;
      }
      prevmulsteps=mulsteps;
    }
  }
  {
    int addsteps=finaladdsteps;
    int mulsteps=min((int)(vmul.size()), m-addsteps);
    //printf("%d %d\n",addsteps,mulsteps);
    printf("%d\n",addsteps+mulsteps);
    vector<int> finalorder;
    for (int i=0;i<addsteps;i++) {
      finalorder.PB(valladd[i].snd);
    }
    sort(finalorder.begin(),finalorder.end());
    for (auto &w:finalorder) {
      printf("%d ",abs(w));
    }
    for (int i=0;i<mulsteps;i++) {
      printf("%d ",vmul[i].snd);
    }
    printf("\n");
  }
}


#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

static char stdinBuffer[1024];
static char* stdinDataEnd = stdinBuffer + sizeof (stdinBuffer);
static const char* stdinPos = stdinDataEnd;

void readAhead(size_t amount)
{
    size_t remaining = stdinDataEnd - stdinPos;
    if (remaining < amount) {
       memmove(stdinBuffer, stdinPos, remaining);
       size_t sz = fread(stdinBuffer + remaining, 1, sizeof (stdinBuffer) - remaining, stdin);
       stdinPos = stdinBuffer;
       stdinDataEnd = stdinBuffer + remaining + sz;
       if (stdinDataEnd != stdinBuffer + sizeof (stdinBuffer))
         *stdinDataEnd = 0;
    }
}

int readInt()
{
    readAhead(16);

    int x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}

const int maxn=1e5+2;
typedef pair<int,int> pii;
pii bestassign[maxn];
vector<pii> vadd[maxn];
vector<pii> vmul;
ll a[maxn];
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  int k=readInt(),n=readInt(),m=readInt();
  for (int i=0;i<k;i++) {
    a[i]=readInt();
  }
  for (int i=1;i<=n;i++) {
    int t=readInt();
    int skill=readInt()-1;
    int b=readInt();
    if (t==1) {
      chkmax(bestassign[skill], MP(b,-i));
    }
    else if (t==2) vadd[skill].PB(MP(b,i));
    else {
      if (b>1) vmul.PB(MP(b,i));
    }
  }
  for (int skill=0;skill<k;skill++) {
    int gain=bestassign[skill].fst - a[skill];
    if (gain>0) {
      vadd[skill].PB(MP(gain, bestassign[skill].snd));
    }
  }
  sort(vmul.begin(),vmul.end(),greater<pii>());
  vector<pair<ld, int> > valladd;
  for (int skill=0;skill<k;skill++) {
    sort(vadd[skill].begin(),vadd[skill].end(),greater<pii>());
    int sz=vadd[skill].size();
    for (auto &w: vadd[skill]) {
      int add=w.fst,id=w.snd;
      ll numer=a[skill]+add;
      ll denom=a[skill];
      ld frac=((ld)denom)/((ld)numer);
      valladd.PB(MP(frac,id));
      a[skill]+=add;
    }
  }
  sort(valladd.begin(),valladd.end());
  int finaladdsteps=min(m,(int)(valladd.size()));
  {
    int addsteps=finaladdsteps;
    int prevmulsteps=min((int)(vmul.size()), m-addsteps);
    --addsteps;
    for (;addsteps>=0;addsteps--) {
      int mulsteps=min((int)(vmul.size()), m-addsteps);
      ld frac=valladd[addsteps].fst;
      //printf("va:%f\n",(double)valladd[addsteps].fst);
      if (mulsteps!=prevmulsteps) {
        frac=frac*vmul[mulsteps-1].fst;
        //printf("vm:%d\n",vmul[mulsteps-1].fst);
      }
      //printf("addsteps:%d mulsteps:%d frac:%f\n",addsteps,mulsteps,(double)frac);
      if (frac>=1) {
        finaladdsteps=addsteps;
      }
      prevmulsteps=mulsteps;
    }
  }
  {
    int addsteps=finaladdsteps;
    int mulsteps=min((int)(vmul.size()), m-addsteps);
    //printf("%d %d\n",addsteps,mulsteps);
    printf("%d\n",addsteps+mulsteps);
    vector<int> finalorder;
    for (int i=0;i<addsteps;i++) {
      finalorder.PB(valladd[i].snd);
    }
    sort(finalorder.begin(),finalorder.end());
    for (auto &w:finalorder) {
      printf("%d ",abs(w));
    }
    for (int i=0;i<mulsteps;i++) {
      printf("%d ",vmul[i].snd);
    }
    printf("\n");
  }
}


#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef __float128 ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

static char stdinBuffer[1024];
static char* stdinDataEnd = stdinBuffer + sizeof (stdinBuffer);
static const char* stdinPos = stdinDataEnd;

void readAhead(size_t amount)
{
    size_t remaining = stdinDataEnd - stdinPos;
    if (remaining < amount) {
       memmove(stdinBuffer, stdinPos, remaining);
       size_t sz = fread(stdinBuffer + remaining, 1, sizeof (stdinBuffer) - remaining, stdin);
       stdinPos = stdinBuffer;
       stdinDataEnd = stdinBuffer + remaining + sz;
       if (stdinDataEnd != stdinBuffer + sizeof (stdinBuffer))
         *stdinDataEnd = 0;
    }
}

int readInt()
{
    readAhead(16);

    int x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}

const int maxn=1e5+2;
typedef pair<int,int> pii;
pii bestassign[maxn];
vector<pii> vadd[maxn];
vector<pii> vmul;
ll a[maxn];
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  int k=readInt(),n=readInt(),m=readInt();
  for (int i=0;i<k;i++) {
    a[i]=readInt();
  }
  for (int i=1;i<=n;i++) {
    int t=readInt();
    int skill=readInt()-1;
    int b=readInt();
    if (t==1) {
      chkmax(bestassign[skill], MP(b,-i));
    }
    else if (t==2) vadd[skill].PB(MP(b,i));
    else {
      if (b>1) vmul.PB(MP(b,i));
    }
  }
  for (int skill=0;skill<k;skill++) {
    int gain=bestassign[skill].fst - a[skill];
    if (gain>0) {
      vadd[skill].PB(MP(gain, bestassign[skill].snd));
    }
  }
  sort(vmul.begin(),vmul.end(),greater<pii>());
  vector<pair<ld, int> > valladd;
  for (int skill=0;skill<k;skill++) {
    sort(vadd[skill].begin(),vadd[skill].end(),greater<pii>());
    int sz=vadd[skill].size();
    for (auto &w: vadd[skill]) {
      int add=w.fst,id=w.snd;
      ll numer=a[skill]+add;
      ll denom=a[skill];
      ld frac=((ld)denom)/((ld)numer);
      valladd.PB(MP(frac,id));
      a[skill]+=add;
    }
  }
  sort(valladd.begin(),valladd.end());
  int finaladdsteps=min(m,(int)(valladd.size()));
  {
    int addsteps=finaladdsteps;
    int prevmulsteps=min((int)(vmul.size()), m-addsteps);
    --addsteps;
    for (;addsteps>=0;addsteps--) {
      int mulsteps=min((int)(vmul.size()), m-addsteps);
      ld frac=valladd[addsteps].fst;
      //printf("va:%f\n",(double)valladd[addsteps].fst);
      if (mulsteps!=prevmulsteps) {
        frac=frac*vmul[mulsteps-1].fst;
        //printf("vm:%d\n",vmul[mulsteps-1].fst);
      }
      //printf("addsteps:%d mulsteps:%d frac:%f\n",addsteps,mulsteps,(double)frac);
      if (frac>=1) {
        finaladdsteps=addsteps;
      }
      prevmulsteps=mulsteps;
    }
  }
  {
    int addsteps=finaladdsteps;
    int mulsteps=min((int)(vmul.size()), m-addsteps);
    //printf("%d %d\n",addsteps,mulsteps);
    printf("%d\n",addsteps+mulsteps);
    vector<int> finalorder;
    for (int i=0;i<addsteps;i++) {
      finalorder.PB(valladd[i].snd);
    }
    sort(finalorder.begin(),finalorder.end());
    for (auto &w:finalorder) {
      printf("%d ",abs(w));
    }
    for (int i=0;i<mulsteps;i++) {
      printf("%d ",vmul[i].snd);
    }
    printf("\n");
  }
}


#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;

static char stdinBuffer[1024];
static char* stdinDataEnd = stdinBuffer + sizeof (stdinBuffer);
static const char* stdinPos = stdinDataEnd;

void readAhead(size_t amount)
{
    size_t remaining = stdinDataEnd - stdinPos;
    if (remaining < amount) {
       memmove(stdinBuffer, stdinPos, remaining);
       size_t sz = fread(stdinBuffer + remaining, 1, sizeof (stdinBuffer) - remaining, stdin);
       stdinPos = stdinBuffer;
       stdinDataEnd = stdinBuffer + remaining + sz;
       if (stdinDataEnd != stdinBuffer + sizeof (stdinBuffer))
         *stdinDataEnd = 0;
    }
}

int readInt()
{
    readAhead(16);

    int x = 0;
    bool neg = false;
    while(*stdinPos==' '||*stdinPos=='\n') ++stdinPos;
    if (*stdinPos == '-') {
       ++stdinPos;
       neg = true;
    }

    while (*stdinPos >= '0' && *stdinPos <= '9') {
       x *= 10;
       x += *stdinPos - '0';
       ++stdinPos;
    }

    return neg ? -x : x;
}

const int maxn=1e5+2;
typedef pair<int,int> pii;
vector<pii> vadd[maxn];
vector<pii> vmul;
ll a[maxn];
int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  int k=readInt(),n=readInt(),m=readInt();
  for (int i=0;i<k;i++) {
    a[i]=readInt();
  }
  for (int i=1;i<=n;i++) {
    int t=readInt();
    int skill_id=readInt()-1;
    int b=readInt();
    if (t==1) {
      if (b>a[skill_id]) vadd[skill_id].PB(MP(b-a[skill_id],-i));
    }
    else if (t==2) vadd[skill_id].PB(MP(b,i));
    else {
      if (b>1) vmul.PB(MP(b,i));
    }
  }
  sort(vmul.begin(),vmul.end(),greater<pii>());
  vector<pair<ld, int> > valladd;
  for (int skill=0;skill<k;skill++) {
    sort(vadd[skill].begin(),vadd[skill].end(),greater<pii>());
    int sz=vadd[skill].size();
    for (auto &w: vadd[skill]) {
      int add=w.fst,id=w.snd;
      ll numer=a[skill]+add;
      ll denom=a[skill];
      ld frac=((ld)denom)/((ld)numer);
      valladd.PB(MP(frac,id));
      a[skill]+=add;
    }
  }
  sort(valladd.begin(),valladd.end());
  int finaladdsteps=min(m,(int)(valladd.size()));
  {
    int addsteps=finaladdsteps;
    int prevmulsteps=min((int)(vmul.size()), m-addsteps);
    --addsteps;
    for (;addsteps>=0;addsteps--) {
      int mulsteps=min((int)(vmul.size()), m-addsteps);
      ld frac=valladd[addsteps].fst;
      //printf("va:%f\n",(double)valladd[addsteps].fst);
      if (mulsteps!=prevmulsteps) {
        frac=frac*vmul[mulsteps-1].fst;
        //printf("vm:%d\n",vmul[mulsteps-1].fst);
      }
      //printf("addsteps:%d mulsteps:%d frac:%f\n",addsteps,mulsteps,(double)frac);
      if (frac>=1) {
        finaladdsteps=addsteps;
      }
      prevmulsteps=mulsteps;
    }
  }
  {
    int addsteps=finaladdsteps;
    int mulsteps=min((int)(vmul.size()), m-addsteps);
    //printf("%d %d\n",addsteps,mulsteps);
    printf("%d\n",addsteps+mulsteps);
    vector<int> finalorder;
    for (int i=0;i<addsteps;i++) {
      finalorder.PB(valladd[i].snd);
    }
    sort(finalorder.begin(),finalorder.end());
    for (auto &w:finalorder) {
      printf("%d ",abs(w));
    }
    for (int i=0;i<mulsteps;i++) {
      printf("%d ",vmul[i].snd);
    }
    printf("\n");
  }
}