#line 1 "verify/yosupo/data-structure/segment_add_get_min_online.test.cpp"
#define PROBLEM "https://judge.yosupo.jp/problem/segment_add_get_min"
#line 2 "template.hpp"
#include <bits/stdc++.h>
using namespace std ;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define RSORT(a) sort(RALL(a))
#define REV(a) reverse(ALL(a))
#define UNI(a) a.erase(unique(ALL(a)),a.end())
#define SZ(a) (int)(a.size())
#define LB(a,x) (int)(lower_bound(ALL(a),x)-a.begin())
#define UB(a,x) (int)(upper_bound(ALL(a),x)-a.begin())
#define MIN(a) *min_element(ALL(a))
#define MAX(a) *max_element(ALL(a))
using ll = long long ;
using db = long double ;
using i128 = __int128_t ;
using u32 = uint32_t ;
using u64 = uint64_t ;
const int INF = INT_MAX / 2 ;
const ll LINF = LLONG_MAX / 4 ;
const db DINF = numeric_limits < db >:: infinity ();
const int MOD = 998244353 ;
const int MOD2 = 1000000007 ;
const db EPS = 1e-9 ;
const db PI = acos ( db ( - 1 ));
template < class T >
using PQ = priority_queue < T , vector < T > , greater < T >> ;
#define vv(T,a,n,...) vector<vector<T>> a(n,vector<T>(__VA_ARGS__))
#define vvv(T,a,n,m,...) vector<vector<vector<T>>> a(n,vector<vector<T>>(m,vector<T>(__VA_ARGS__)))
#define vvvv(T,a,n,m,k,...) vector<vector<vector<vector<T>>>> a(n,vector<vector<vector<T>>>(m,vector<vector<T>>(k,vector<T>(__VA_ARGS__))))
template < class T , class U >
bool chmin ( T & a , U b ){ return b < a ? a = b , 1 : 0 ;}
template < class T , class U >
bool chmax ( T & a , U b ){ return a < b ? a = b , 1 : 0 ;}
template < class T , class U >
T SUM ( const U & a ){ return accumulate ( ALL ( a ), T {});}
mt19937 rng ( chrono :: steady_clock :: now (). time_since_epoch (). count ());
mt19937_64 rng64 ( chrono :: steady_clock :: now (). time_since_epoch (). count ());
#line 2 "data-structure/convex/dynamic-li-chao-tree.hpp"
/**
* Author: Teetat T.
* Date: 2024-06-12
* Description: Dynamic Li-Chao Tree (minimize).
*/
template < class T >
struct DynamicLiChaoTree {
static const T INF = numeric_limits < T >:: max () / 2 ;
struct Line {
T m , c ;
Line ( T _m , T _c ) : m ( _m ), c ( _c ){}
inline T eval ( T x ) const { return m * x + c ;}
};
struct Node ;
using Ptr = Node * ;
struct Node {
Line v ;
Ptr l , r ;
Node () : v ( 0 , INF ), l ( nullptr ), r ( nullptr ){}
Node ( Line _v ) : v ( _v ), l ( nullptr ), r ( nullptr ){}
};
ll lb , ub ;
Ptr root ;
DynamicLiChaoTree ( ll _lb , ll _ub ) : lb ( _lb ), ub ( _ub ), root ( nullptr ){}
void insert ( T l , T r , Ptr & t , Line v ){
if ( ! t ) return void ( t = new Node ( v ));
T m = l + ( r - l ) / 2 ;
if ( v . eval ( m ) < t -> v . eval ( m )) swap ( t -> v , v );
if ( v . eval ( l ) < t -> v . eval ( l )) insert ( l , m , t -> l , v );
if ( v . eval ( r ) < t -> v . eval ( r )) insert ( m + 1 , r , t -> r , v );
}
inline void insert ( T m , T c ){
insert ( lb , ub , root , Line ( m , c ));
}
void insert_range ( T l , T r , Ptr & t , T x , T y , Line v ){
if ( y < l || r < x ) return ;
if ( ! t ) t = new Node ();
if ( x <= l && r <= y ) return insert ( l , r , t , v );
T m = l + ( r - l ) / 2 ;
insert_range ( l , m , t -> l , x , y , v );
insert_range ( m + 1 , r , t -> r , x , y , v );
}
inline void insert_range ( T m , T c , T x , T y ){
insert_range ( lb , ub , root , x , y , Line ( m , c ));
}
T query ( T l , T r , Ptr t , T x ){
if ( ! t ) return INF ;
T m = l + ( r - l ) / 2 ;
if ( x <= m ) return min ( t -> v . eval ( x ), query ( l , m , t -> l , x ));
return min ( t -> v . eval ( x ), query ( m + 1 , r , t -> r , x ));
}
inline T query ( T x ){
return query ( lb , ub , root , x );
}
};
#line 4 "verify/yosupo/data-structure/segment_add_get_min_online.test.cpp"
int main (){
cin . tie ( nullptr ) -> sync_with_stdio ( false );
int n , q ;
cin >> n >> q ;
const int X = 1e9 ;
DynamicLiChaoTree < ll > lct ( - X , X );
while ( n -- ){
ll l , r , a , b ;
cin >> l >> r >> a >> b ;
lct . insert_range ( a , b , l , r - 1 );
}
while ( q -- ){
int op ;
cin >> op ;
if ( op ){
ll x ;
cin >> x ;
ll res = lct . query ( x );
if ( res >= lct . INF ) cout << "INFINITY \n " ;
else cout << res << " \n " ;
} else {
ll l , r , a , b ;
cin >> l >> r >> a >> b ;
lct . insert_range ( a , b , l , r - 1 );
}
}
}