// In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int ll

#define PB push_back
#define PF push_front
#define MP make_pair
#define FF first
#define SS second
#define _sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

struct pok { int cnt[5]; };

int const N = 1e5 + 20, SQ = 333;
int n;
vector <vector <int>> vec;
vector <pok> C;

inline void recalc (int i){
	C[i] = {0, 0, 0, 0, 0};
	for (int j = 0; j < _sz(vec[i]); j ++)
		C[i].cnt[(j + 1) % 5] += vec[i][j];
}

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	while (n --){
		string s;
		cin >> s;

		if (s == "add"){
			int x; cin >> x;

			for (int i = 0; i < _sz(vec); i ++){
				if ((!i || vec[i][0] < x) && (i == _sz(vec) - 1 || vec[i + 1][0] > x)){
					vec[i].insert(upper_bound(vec[i].begin(), vec[i].end(), x), x);

					if (_sz(vec[i]) == 2 * SQ){
						vector <int> tmp;

					  	for (int t = 0; t < SQ; t ++){
							tmp.PB(vec[i].back());
							vec[i].pop_back();
						}

						C.insert(C.begin() + i + 1, {0, 0, 0, 0, 0});
						reverse(tmp.begin(), tmp.end());
						vec.insert(vec.begin() + i + 1, tmp);

						recalc(i + 1);
					}

					recalc(i);

				  	break;
				}
			}

			if (!_sz(vec)){
				vec.PB({x});
				C.PB({0, x, 0, 0, 0});
			}

/*		    for (int i = 0; i < _sz(vec); i ++){
				cout << i << ":  "; for (auto x: vec[i]) cout << x << ' ';
				cout << '\t'; for (int j = 0; j < 5; j ++) cout << C[i].cnt[j] << ' ';
				cout << endl;
			}
*/
		}
		else if (s == "del"){
		  	int x; cin >> x;
			for (int i = 0; i < _sz(vec); i ++)
				if (vec[i][0] <= x && vec[i].back() >= x){
					for (int j = 0; j < _sz(vec[i]); j ++){
						if (vec[i][j] == x) vec[i].erase(vec[i].begin() + j);
						break;
					}
					recalc(i);
				}
		}
		else {
			int st = 0, res = 0;
			for (int i = 0; i < _sz(vec); i ++){
				res += C[i].cnt[(5 - st + 3) % 5];
			  	(st += _sz(vec[i])) %= 5;
			}

			cout << res << '\n';
		}
	}
}


// In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int ll

#define PB push_back
#define PF push_front
#define MP make_pair
#define FF first
#define SS second
#define _sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

struct pok { int cnt[5]; };

int const N = 1e5 + 20, SQ = 333;
int n;
vector <vector <int>> vec;
vector <pok> C;

inline void recalc (int i){
	C[i] = {0, 0, 0, 0, 0};
	for (int j = 0; j < _sz(vec[i]); j ++)
		C[i].cnt[(j + 1) % 5] += vec[i][j];
}

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	while (n --){
		string s;
		cin >> s;

		if (s == "add"){
			int x; cin >> x;

			for (int i = 0; i < _sz(vec); i ++){
				if ((!i || vec[i][0] < x) && (i == _sz(vec) - 1 || vec[i + 1][0] > x)){
					vec[i].insert(upper_bound(vec[i].begin(), vec[i].end(), x), x);

					if (_sz(vec[i]) == 2 * SQ){
						vector <int> tmp;

					  	for (int t = 0; t < SQ; t ++){
							tmp.PB(vec[i].back());
							vec[i].pop_back();
						}

						C.insert(C.begin() + i + 1, {0, 0, 0, 0, 0});
						reverse(tmp.begin(), tmp.end());
						vec.insert(vec.begin() + i + 1, tmp);

						recalc(i + 1);
					}

					recalc(i);

				  	break;
				}
			}

			if (!_sz(vec)){
				vec.PB({x});
				C.PB({0, x, 0, 0, 0});
			}

/*		    for (int i = 0; i < _sz(vec); i ++){
				cout << i << ":  "; for (auto x: vec[i]) cout << x << ' ';
				cout << '\t'; for (int j = 0; j < 5; j ++) cout << C[i].cnt[j] << ' ';
				cout << endl;
			}
*/
		}
		else if (s == "del"){
		  	int x; cin >> x;
			for (int i = 0; i < _sz(vec); i ++)
				if (vec[i][0] <= x && vec[i].back() >= x){
					for (int j = 0; j < _sz(vec[i]); j ++)
						if (vec[i][j] == x){
							vec[i].erase(vec[i].begin() + j);
							break;
						}
					recalc(i);
					break;
				}
		}
		else {
			int st = 0, res = 0;
			for (int i = 0; i < _sz(vec); i ++){
				res += C[i].cnt[(5 - st + 3) % 5];
			  	(st += _sz(vec[i])) %= 5;
			}

			cout << res << '\n';
		}
	}
}


// In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int ll

#define PB push_back
#define PF push_front
#define MP make_pair
#define FF first
#define SS second
#define _sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

int const N = 1e5 + 20;
int n, a[N];
map <int, int> mp;
vector <int> vec;
string s[N];

struct node {
  	int num, cnt[5];
} seg[N << 2];

inline void update (const int& v, const int& lc, const int& rc){
	for (int i = 0; i < 5; i ++)
	  	seg[v].cnt[i] = seg[lc].cnt[i] + seg[rc].cnt[(i + 5 - seg[lc].num) % 5];
	seg[v].num = seg[lc].num + seg[rc].num;
}

void modify (int idx, int val, int v = 1, int s = 0, int e = n){
	if (s + 1 == e){
		seg[v].cnt[0] += val;
	  	if (val > 0) seg[v].num ++;
		else seg[v].num --;
		seg[v].num = (seg[v].num + 5) % 5;

		return ;
	}

	int mid = (s + e) >> 1, lc = v << 1, rc = lc | 1;
	if (idx < mid) modify(idx, val, lc, s, mid);
	else modify(idx, val, rc, mid, e);

	update(v, lc, rc);
}

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 0; i < n; i ++){
		cin >> s[i];
		if (s[i] != "sum"){
			cin >> a[i];
			vec.PB(a[i]);
		}
	}

	sort(vec.begin(), vec.end());
	vec.resize( unique(vec.begin(), vec.end()) - vec.begin() );

	for (int i = 0; i < _sz(vec); i ++) mp[vec[i]] = i;

	for (int i = 0; i < n; i ++){
		if (s[i] == "add")
		  	modify(mp[a[i]], a[i]);
		else if (s[i] == "del")
		  	modify(mp[a[i]], -a[i]);
		else
		  	cout << seg[1].cnt[2] << '\n';

//		for (int j = 0; j < 5; j ++) cout << ' ' << seg[1].cnt[j]; cout << '\n';
	}
}


// In the name of ALLAH
#include <bits/stdc++.h>
using namespace std;

#define int ll

#define PB push_back
#define PF push_front
#define MP make_pair
#define FF first
#define SS second
#define _sz(x) (int)x.size()

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

struct pok { int cnt[5]; };

int const N = 1e5 + 20, SQ = 333;
int n;
vector <vector <int>> vec;
vector <pok> C;

inline void recalc (int i){
	C[i] = {0, 0, 0, 0, 0};
	for (int j = 0; j < _sz(vec[i]); j ++)
		C[i].cnt[(j + 1) % 5] += vec[i][j];
}

int32_t main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	while (n --){
		string s;
		cin >> s;

		if (s == "add"){
			int x; cin >> x;

			for (int i = 0; i < _sz(vec); i ++){
				if ((!i || vec[i][0] < x) && (i == _sz(vec) - 1 || vec[i + 1][0] > x)){
					vec[i].insert(upper_bound(vec[i].begin(), vec[i].end(), x), x);

					if (_sz(vec[i]) == 2 * SQ){
						vector <int> tmp;

					  	for (int t = 0; t < SQ; t ++){
							tmp.PB(vec[i].back());
							vec[i].pop_back();
						}

						C.insert(C.begin() + i + 1, {0, 0, 0, 0, 0});
						reverse(tmp.begin(), tmp.end());
						vec.insert(vec.begin() + i + 1, tmp);

						recalc(i + 1);
					}

					recalc(i);

				  	break;
				}
			}

			if (!_sz(vec)){
				vec.PB({x});
				C.PB({0, x, 0, 0, 0});
			}

/*		    for (int i = 0; i < _sz(vec); i ++){
				cout << i << ":  "; for (auto x: vec[i]) cout << x << ' ';
				cout << '\t'; for (int j = 0; j < 5; j ++) cout << C[i].cnt[j] << ' ';
				cout << endl;
			}
*/
		}
		else if (s == "del"){
		  	int x; cin >> x;
			for (int i = 0; i < _sz(vec); i ++)
				if ((!i || vec[i][0] < x) && (i == _sz(vec) - 1 || vec[i + 1][0] > x)){
					for (int j = 0; j < _sz(vec[i]); j ++)
						if (vec[i][j] == x) vec[i].erase(vec[i].begin() + j);
					recalc(i);
				}
		}
		else {
			int st = 0, res = 0;
			for (int i = 0; i < _sz(vec); i ++){
				res += C[i].cnt[(5 - st + 3) % 5];
			  	(st += _sz(vec[i])) %= 5;
			}

			cout << res << '\n';
		}
	}
}


s =  raw_input()

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

def calc(s):
    if s == '':
        return 1
    return sum(map(mul,s.split("+")))

l = s.split("*")

ans = 0

# print l

for i in xrange(len(l)):
    for j in xrange(i,len(l)):
        x = calc("*".join(l[i:j]))
        ss = "*".join(l[:i]) +  "*" +  str(x) + "*" + "*".join(l[j:])
        if ss[0] == "*":
            ss = ss[1:]
        if ss[-1] == "*":
            ss = ss[:-1]
        # print ss
        ans = max(ans,calc(ss))

print ans


s = raw_input()

l = s.split("*")

m = (0,0)

for i in xrange(len(l)):
    x = sum(map(int,l[i].split("+")))
    if x > m[0]:
        m = (x,i)

l[m[1]] = str(m[0])

# print l

s = "*".join(l)

# print s

l = s.split("+")

# print l

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

print sum(map(mul,l))


s = raw_input()

def mul(s):
    ans = 1
    l = map(int,s.split("*"))
    for i in l:
        ans = ans*i
    return ans

def calc(s):
    if s == '':
        return 0
    return sum(map(mul,s.split("+")))

l = s.split("*")

ans = 0

# print l

for i in xrange(len(l)):
    x = calc(l[i])
    ss = "*".join(l[:i]) +  "*" +  str(x) + "*" + "*".join(l[i+1:])
    if ss[0] == "*":
        ss = ss[1:]
    if ss[-1] == "*":
        ss = ss[:-1]
    ans = max(ans,calc(ss))

print ans


e = raw_input()

n, ans = len(e), eval(e)

for i in xrange(-1, n):
	if i == -1 or e[i] == '*':
		for j in xrange(i + 1, n + 1):
			if j == n or e[j] == '*':
				ans = max(ans, eval(e[:i + 1] + '(' +  e[i + 1: j] + ')' + e[j:]))
print(ans)


t=raw_input()
s=""
strsize=len(t)
temp=0
mylist=[]
maxi=eval(t)
for i in range(strsize):
	if t[i]== '*':
		mylist.append(i)
countStar=len(mylist)
for i in range(countStar):
	x=mylist[i]+1
	#print x
	for j in range(i+1,countStar):
		y=mylist[j]

		s=t[:x]+'('+t[x:y]+')'+t[y:]
		temp= eval(s)

		if temp>maxi:
			maxi=temp

print maxi


# your code goes here
import sys
mystring=sys.stdin.readline()

s=mystring
max=0
last=len(mystring)
max=0

for x in range(0,last,2):
    for y in range(x+3,last,2):
        s=mystring[:x]+'('+mystring[x:y]+')'+mystring[y:]
        t=eval(s)
        if t>max:
            max=t
print max


t=raw_input()
s=""
strsize=len(t)
temp=0
mylist=[]
maxi=eval(t)
for i in range(strsize):
	if t[i]== '*':
		mylist.append(i)

for x in mylist:
	x=x+1
	for y in range(x+1,strsize,2):
		s=t[:x]+'('+t[x:y]+')'+t[y:]
		temp= eval(s)

		if temp>maxi:
			maxi=temp

for x in mylist:
	for y in range(0,x,2):
		s=t[:y]+'('+t[y:x]+')'+t[x:]
		temp= eval(s)

		if temp>maxi:
			maxi=temp
print maxi


t=raw_input()
s=""
strsize=len(t)
temp=0
mylist=[]

maxi=eval(t)
mylist.append(-1)
for i in range(strsize):
	if t[i]== '*':
		mylist.append(i)
mylist.append(strsize)

countStar=len(mylist)
for i in range(countStar):
	x=mylist[i]+1
	#print x
	for j in range(i+1,countStar):
		y=mylist[j]

		s=t[:x]+'('+t[x:y]+')'+t[y:]
		#print s
		temp= eval(s)

		if temp>maxi:
			maxi=temp

print maxi


t=raw_input()
s=""
strsize=len(t)
temp=0
mylist=[]
mylist.append(0)
maxi=eval(t)
for i in range(strsize):
	if t[i]== '*':
		mylist.append(i)
countStar=len(mylist)
for i in range(countStar):
	x=mylist[i]+1
	#print x
	for j in range(i+1,countStar):
		y=mylist[j]

		s=t[:x]+'('+t[x:y]+')'+t[y:]
		temp= eval(s)

		if temp>maxi:
			maxi=temp

print maxi


s = raw_input()
ans = eval(s)
n = len(s)
for i in xrange(-1,n):
    if i == -1 or s[i] == '*':
        for j in xrange(i + 1,n + 1):
            if j == n or s[j] == '*':
                v = s[0:i+1] + "(" + s[i+1:j] + ")" + s[j:n]
                ans = max(ans,eval(v))
print ans


s = raw_input()
ans = eval(s)
n = len(s)
for i in xrange(-1,n):
    if i == -1 or s[i] == '*':
        for j in xrange(i + 1,n + 1):
            if j == n + 1 or s[j] == '*':
                v = s[0:i+1] + "(" + s[i+1:j] + ")" + s[j:n]
                ans = max(ans,eval(v))
print ans


str=raw_input()
n,ans=len(str),eval(str)
for i in range(-1,n):
    if i==-1 or str[i]=='*':
        for j in range(i+1,n+1):
            if j==n or str[j]=='*':
                ans=max(ans,eval(str[:i+1]+'('+str[i+1:j]+')'+str[j:]))
print ans


expr = raw_input()
lst = []

lst.append(-1)
for i, c in enumerate(expr):
    if c == '*':
        lst.append(i)
lst.append(len(expr))

val = eval(expr)
for i in range(len(lst)):
    for j in range(i+1, len(lst)):
        a, b = lst[i], lst[j]
        nexpr = expr[:a+1] + '(' + expr[a+1:b] + ')' + expr[b:]
        val = max(val, eval(nexpr))

print val


import sys
import re

exp_str = raw_input()

ps = [-1] + [m.start() for m in re.finditer('\*', exp_str)] + [len(exp_str)]

if not ps:
    print eval(exp_str)
else:
    ans = eval(exp_str)
    n = len(ps)
    for i in xrange(n):
        for j in xrange(i + 1, n):
            ii = ps[i]
            jj = ps[j]
            s = exp_str[:ii + 1] + "(" + exp_str[ii + 1: jj] + ")" + exp_str[jj:]
            ans = max(ans, eval(s))

    print ans


e = raw_input()

n, result = len(e), eval(e)
for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[:i + 1] + '(' + e[i + 1:j] + ')' + e[j:]))
print(result)


s=raw_input()

ans=eval(s)
prev=0
for i in range(len(s)):
    if s[i]=='*':
        if prev!=0:
            lol=(s[0:prev])+'*('+(s[prev+1:i])+')*'+(s[i+1:])
        else:
            lol='('+s[0:i]+')'+s[i:]
        temp=eval(lol)
        if temp>ans:
                ans=temp
        prev=i
n=len(s)-1
if(prev<n):
    lol=s[0:prev+1]+'('+s[prev+1:]+')'
    temp=eval(lol)
    if temp>ans:
        ans=temp

print ans


s=raw_input()

ans=eval(s)
prev=0
for i in range(len(s)):
    if s[i]=='*':
        if prev!=0:
            lol=(s[0:prev])+'*('+(s[prev+1:i])+')*'+(s[i+1:])
        else:
            lol='('+s[0:i]+')'+s[i:]
        temp=eval(lol)
        if temp>ans:
                ans=temp
        prev=i
n=len(s)-1
if(prev<n and prev!=0):
    lol=s[0:prev+1]+'('+s[prev+1:]+')'
    temp=eval(lol)
    if temp>ans:
        ans=temp

print ans


s=raw_input()
l=[0]
ans=eval(s)
prev=0
for i in range(len(s)):
    if s[i]=='*':
        l.append(i+1)
l.append(len(s)+1)
for i in range(len(l)):
    st=l[i]
    for j in range(i+1,len(l)):
        end=l[j]
        #print st,end,
        lol=(s[:st])+'('+(s[st:end-1])+')'+(s[end-1:])
        temp=eval(lol)
        #print lol
        if temp>ans:
                ans=temp

print ans


s=raw_input()
l=[-1]
ans=eval(s)
prev=0
for i in range(len(s)):
    if s[i]=='*':
        l.append(i)
l.append(len(s))
for i in range(len(l)):
    st=l[i]
    for j in range(i+1,len(l)):
        end=l[j]
        #print st,end
        lol=s[:st+1]+'('+s[st+1:end]+')'+s[end:]
        temp=eval(lol)
        if temp>ans:
               ans=temp

print ans

#   0 1 2 3 . . .  . n-1 n
#       |            |
# * <<<<<string>>>>>>>>> *
# 0 1 2 3............n  n+1
#       |            |
#idea: (start till first *)+(beyond * till just before next *)+(* and remaining till end)


s=raw_input()

ans=eval(s)
prev=0
for i in range(len(s)):
    if s[i]=='*':
        if prev!=0:
            lol=(s[0:prev])+'*('+(s[prev+1:i])+')*'+(s[i+1:])
            temp=eval(lol)
            if temp>ans:
                ans=temp
        prev=i

print ans


s = raw_input()
l = len(s)
ans = eval(s)
pre = [-1]
for i in range(l+1):
    if (i==l or (i%2==1 and s[i]=='*')):
        for x in pre:
            cnt = eval(s[:x+1]+"("+s[x+1:i]+")"+s[i:])
            ans=max(ans,cnt);
        pre.append(i)
print ans


x = []
def cal(a,sp=1):
    n = len(a)
    st = []
    while(len(st) > 0):
        st.pop()
    i = 0
    while(i < n):
        if(a[i] >= '0' and a[i] <= '9'):
            st.append((long)(a[i]))
        elif(a[i] == '*'):
            u = st[len(st)-1]
            st.pop()
            if(a[i+1] == 'x'):
                u *= sp
            else:
                u *= (long)(a[i+1])
            st.append(u)
            i += 1
        i += 1
    return sum(st)
def main():
    s = raw_input()
    s = '1*' + s + '*1'
    n = len(s)
    ans = cal(s)
    for i in xrange(n):
        if(s[i] == '*'):
            x.append(i)
    sz = len(x)
    for i in xrange(sz):
        for j in xrange(i+1,sz):
            l = x[i]
            r = x[j]
            if(l + 1 == r - 1):
                continue
            sp = cal(s[l+1:r])
            ss = s[:l+1] + 'x' + s[r:]
            ans = max(ans,cal(ss,sp))
    print(ans)
main()


sp = 1
x = []
def cal(a):
    n = len(a)
    st = []
    while(len(st) > 0):
        st.pop()
    i = 0
    while(i < n):
        if(a[i] >= '0' and a[i] <= '9'):
            st.append((long)(a[i]))
        elif(a[i] == '*'):
            u = st[len(st)-1]
            st.pop()
            if(a[i+1] == 'x'):
                u *= sp
            else:
                u *= (long)(a[i+1])
            st.append(u)
            i += 1
        i += 1
    return sum(st)
def main():
    s = raw_input()
    s = '1*' + s + '*1'
    n = len(s)
    ans = cal(s)
    for i in xrange(n):
        if(s[i] == '*'):
            x.append(i)
    sz = len(x)
    for i in xrange(sz):
        for j in xrange(i+1,sz):
            l = x[i]
            r = x[j]
            if(l + 1 == r - 1):
                continue
            global sp
            sp = cal(s[l+1:r])
            ss = s[:l+1] + 'x' + s[r:]
            ans = max(ans,cal(ss))
    print(ans)
main()


s = str(raw_input())
ans = 0
for i in range(len(s) // 2 + 1):
    for j in range(i, len(s) // 2 + 1):
        i1 = 2 * i
        j1 = 2 * j + 1
        ans = max(eval(s[0:i1] + '(' + s[i1:j1] + ')' + s[j1:len(s)]), ans)
print(ans)


s = str(raw_input())
ans = eval(s)
for i in range(len(s)):
    if s[i] == '*':
        for j in range(i + 1, len(s)):
            if s[j] == '*':
                ans = max(ans, eval(s[0:(i + 1)] + '(' + s[(i + 1):j] + ')' + s[j:len(s)]))

for i in range(len(s)):
    if s[i] == '*':
        ans = max(ans, eval('(' + s[0:i] + ')' + s[i:len(s)]))
        ans = max(ans, eval(s[0:(i + 1)] + '(' + s[(i + 1):len(s)] + ')'))

print(ans)


arithmeticExpression = raw_input()
lst = (eval(arithmeticExpression))
list = []
for i in range(len(arithmeticExpression)-1) :
    if arithmeticExpression[i] != '+' and arithmeticExpression[i] != '*':
        list.append(i)
for index in range(len(list)) :
    for index2 in range(len(list)) :
        if index <> index2:
            lst = max(lst,eval(arithmeticExpression[:min(list[index],list[index2])]+"("+arithmeticExpression[min(list[index],list[index2]):max(list[index],list[index2])+1]+")"+arithmeticExpression[max(list[index],list[index2])+1:]))
print(lst)


arithmeticExpression = raw_input()
lst = (eval(arithmeticExpression))
for index in range(-1, len(arithmeticExpression)):
    if index == -1 or arithmeticExpression[index] == '*':
        for j in range(index + 1, len(arithmeticExpression) + 1):
            if j == len(arithmeticExpression) or arithmeticExpression[j] == '*':
                lst = max(lst, eval(arithmeticExpression[:index + 1] + '(' +  arithmeticExpression[index + 1: j] + ')' + arithmeticExpression[j:]))
print(lst)


e = raw_input()

n, result = len(e), eval(e)
for i in xrange(-1, n):
  if i == -1 or e[i] == '*':
    for j in xrange(i + 1, n + 1):
      if j == n or e[j] == '*':
        result = max(result, eval(e[:i + 1] + '(' + e[i + 1:j] + ')' + e[j:]))
print(result)


A = '1*' + raw_input() + '*1'
n = len(A)
ans = eval(A)
t = [i for i in xrange(n) if A[i] == '*']

for i in xrange(len(t)):
    for j in xrange(i + 1, len(t)):
        x, y = t[i], t[j]
        exp = '%s*(%s)*%s' % (A[:x], A[x+1:y], A[y+1:])
        ans = max(ans, eval(exp))
print ans


strs=raw_input()
ans=0
arr=[]
for i in range(len(strs)):
    if strs[i]=='*':
        arr.append(i)
for i in range(len(arr)):
    for j in range(i):
        strtemp=strs[:arr[i]] + ')' + strs[arr[i]:]
        strtemp=strtemp[:arr[j]+1] + '(' + strtemp[arr[j]+1:]
        ans=max(ans,eval(strtemp))
    strtemp=strs[:arr[i]]+')'+strs[arr[i]:]
    strtemp='('+strtemp
    ans=max(ans,eval(strtemp))
    for j in range(i+1,len(arr)):
        strtemp=strs[:arr[i]+1] + '(' + strs[arr[i]+1:]
        strtemp=strtemp[:arr[j]+1] + ')' + strtemp[arr[j]+1:] #The length of the string gets increased by 1
        ans=max(ans,eval(strtemp))
    strtemp=strs[:arr[i]+1]+'('+strs[arr[i]+1:]
    strtemp=strtemp+')'
    ans=max(ans,eval(strtemp))
print ans


strs=raw_input()
ans=0
arr=[]
for i in range(len(strs)):
    if strs[i]=='*':
        arr.append(i)
for i in range(len(arr)):
    for j in range(i):
        strtemp=strs[:arr[i]] + ')' + strs[arr[i]:]
        strtemp=strtemp[:arr[j]+1] + '(' + strtemp[arr[j]+1:]
        ans=max(ans,eval(strtemp))
    strtemp=strs[:arr[i]]+')'+strs[arr[i]:]
    strtemp='('+strtemp
    ans=max(ans,eval(strtemp))
    for j in range(i+1,len(arr)):
        strtemp=strs[:arr[i]+1] + '(' + strs[arr[i]+1:]
        strtemp=strtemp[:arr[j]+1] + ')' + strtemp[arr[j]+1:] #The length of the string gets increased by 1
        ans=max(ans,eval(strtemp))
    strtemp=strs[:arr[i]+1]+'('+strs[arr[i]+1:]
    strtemp=strtemp+')'
    ans=max(ans,eval(strtemp))
ans=max(ans,eval(strs))
print ans


s=raw_input()
ans=eval(s)
l=len(s)
for i in xrange(-1,l-1):
    if i==-1 or s[i]=='*':
        for j in xrange(i+1,l+1):
            if j==l or s[j]=='*':
                ans=max(ans,eval(s[:i+1]+'('+s[i+1:j]+')'+s[j:]))
print ans


a = raw_input()
ans = eval(a)
n = len(a)
for i in range(-1, n):
    if i == -1 or a[i] == '*':
        for j in range(i + 1, n ):
            if  a[j] == '*':
                temp = a[0:i + 1] + "(" + a[i + 1:j] + ")" + a[j:n]
                ans = max(ans, eval(temp))
print(ans)


a = raw_input()
ans = eval(a)
n = len(a)
for i in range(-1, n):
    if i == -1 or a[i] == '*':
        for j in range(i + 1, n+1 ):
            if  j==n or a[j] == '*':
                temp = a[:i + 1] + "(" + a[i + 1:j] + ")" + a[j:]
                ans = max(ans, eval(temp))
print(ans)


def main():
    s = raw_input()
    ss = s
    res = eval(ss)
    for idx in range(len(ss)):
        if idx == 0 or ss[idx-1] == '*':
            for idx2 in range(idx+1, len(ss)):
                if idx2 == len(ss)-1 or ss[idx2+1] == '*':
                    res = max(res, eval(ss[:idx]+'('+ss[idx:idx2+1]+')'+ss[idx2+1:]))
    print res

if __name__ == '__main__':
    main()


str=raw_input()
n,sum=len(str),eval(str)
for i in xrange(-1,n):
    if i==-1 or str[i]=='*':
        for j in xrange(i+1,n+1):
            if j==n or str[j]=='*':
                sum=max(sum,eval(str[:i+1]+'('+str[i+1:j]+')'+str[j:]))
print sum


a = raw_input()
n = len(a)
p = [-1]
ans = 0
for i in xrange(n + 1):
    if i == n or a[i] == '*':
        for j in p:
            ans = max(ans, eval(a[:j + 1] + "(" + a[j + 1: i] + ")" + a[i:]))
        p.append(i)
print ans


s = raw_input()
a = []
a.append(0)
for i in range(len(s)):
	if s[i] == '*':
		a.append(i + 1)
a.append(len(s) + 1)
ans = eval(s)
for i in range(len(a)):
	for j in range(i + 1, len(a)):
		ans = max(ans, eval(s[:a[i]] + "(" + s[a[i]:a[j] - 1] + ")" + s[a[j] - 1:]))
print ans


s = raw_input()
best = eval(s)

stars = [-1]
ofst = 0
while ofst < len(s):
  l = s.find('*', ofst)
  if l < 0:
    break
  stars.append(l)
  ofst = l + 1
stars.append(len(s))

for il in xrange(len(stars)):
  for ir in xrange(il + 1, len(stars)):
    l = stars[il]
    r = stars[ir]
    expr = s[:(l + 1)] + '(' + s[(l + 1):r] + ')' + s[r:]
    #print expr
    cand = eval(expr)
    best = max(best, cand)

print best


s = raw_input()
best = eval(s)
ofst = -1
while True:
  if ofst < 0:
    l = -1
  else:
    l = s.find('*', ofst)
    if l < 0:
      break
  r = s.find('*', l + 1)
  if r < 0:
    r = len(s)
  expr = s[:(l + 1)] + '(' + s[(l + 1):r] + ')' + s[r:]
  #print expr
  cand = eval(expr)
  best = max(best, cand)
  ofst = l + 1

print best


s = raw_input()
best = eval(s)

stars = [-1]
ofst = 0
while ofst < len(s):
  l = s.find('*', ofst)
  if l < 0:
    break
  stars.append(l)
  ofst = l + 1
stars.append(len(s))

for il in xrange(len(stars)):
  for ir in xrange(il + 1, len(stars) - 1):
    l = stars[il]
    r = stars[ir]
    expr = s[:(l + 1)] + '(' + s[(l + 1):r] + ')' + s[r:]
    #print expr
    cand = eval(expr)
    best = max(best, cand)

print best


str = raw_input()
str = "1*" + str + "*1"
n = len(str)
res = 0
for i in range(n):
    if str[i] == '*':
        for j in range(i + 1 , n):
            if str[j] == '*':
                res = max(res , eval(str[:i+1] + "(" + str[i+1:j] + ")" + str[j:]))
print res


"""
    Author: Hemanth Kumar Veeranki
    Handle:harry7

"""
#!/usr/bin/python
inp=raw_input()
ans=0
a=[]
n=len(inp)
for i in xrange(n):
    if inp[i]=='*':
        a.append(i)
n=len(a)
for i in xrange(n):
    for j in xrange(i):
        tmp=inp[:a[i]] + ')' + inp[a[i]:]
        tmp=tmp[:a[j]+1] + '(' + tmp[a[j]+1:]
        ans=max(ans,eval(tmp))
    tmp=inp[:a[i]]+')'+inp[a[i]:]
    tmp='('+tmp
    ans=max(ans,eval(tmp))
    for j in xrange(i+1,n):
        tmp=inp[:a[i]+1] + '(' + inp[a[i]+1:]
        tmp=tmp[:a[j]+1] + ')' + tmp[a[j]+1:]
        ans=max(ans,eval(tmp))
    tmp=inp[:a[i]+1]+'('+inp[a[i]+1:]
    tmp=tmp+')'
    ans=max(ans,eval(tmp))
ans=max(ans,eval(inp))
print ans


import math
import string
pa = {}
x = 0
s = raw_input()
i = 0
ans = eval(s)
s = "1*" + s[:] + "*1"
while i < len(s):
	if s[i] == '*':
		pa[x] = i
		x = x + 1
	i = i + 1
i = 0
while i < x:
	j = i + 1
	while j < x:
		s2 = s[:pa[i]+1] + '(' + s[pa[i]+1:pa[j]] + ')' + s[pa[j]:]
		ans2 = eval(s2)
		if (ans2 > ans):
			ans = ans2
		j = j + 1
	i = i + 1
print ans


fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_line(&mut input_str).expect("read error");

    let mut pos = [0; 2502];
    let mut val = [0; 2502];
    let mut cnt = 0;
    let mut base = 1i32;
    for (i, ch_i) in input_str.trim().chars().enumerate() {
        if ch_i == '+' {
            pos[cnt] = i;
            val[cnt] = base;
            base = 1;
            cnt += 1;
        } else if ch_i == '*' {
            // do nothing
        } else {
            base *= ch_i.to_digit(10).unwrap() as i32;
        }
    }
    val[cnt] = base;

    let mut ans = base;
    let mut left = 0;
    let bytes = input_str.as_bytes();
    for i in 0..cnt {
        let left_p = *bytes.get(pos[i]-1).unwrap() as i32 - 48;
        let left_m = val[i] / left_p;

        let mut tot = 0;
        for j in i+1..cnt {
            tot += val[j];
        }
        let mut right = 0;
        for j in (i..cnt).rev() {
            let right_p = *bytes.get(pos[j]+1).unwrap() as i32 - 48;
            let right_m = val[j+1] / right_p;
            ans = std::cmp::max(
                ans,
                left + left_m * (left_p + tot + right_p) * right_m + right);

            tot -= val[j];
            right += val[j+1];
        }

        left += val[i];
    }
    println!("{}", ans);
}


fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_line(&mut input_str).expect("read error");

    let mut pos = [0; 2502];
    let mut val = [0u64; 2502];
    let mut cnt = 0;
    let mut base = 1u64;
    for (i, ch_i) in input_str.trim().chars().enumerate() {
        if ch_i == '+' {
            pos[cnt] = i;
            val[cnt] = base;
            base = 1;
            cnt += 1;
        } else if ch_i == '*' {
            // do nothing
        } else {
            base *= ch_i.to_digit(10).unwrap() as u64;
        }
    }
    val[cnt] = base;

    let mut ans = base;
    let mut left = 0;
    let bytes = input_str.as_bytes();
    for i in 0..cnt {
        let left_p = *bytes.get(pos[i]-1).unwrap() as u64 - 48;
        let left_m = val[i] / left_p;

        let mut tot = 0;
        for j in i+1..cnt {
            tot += val[j];
        }
        let mut right = 0;
        for j in (i..cnt).rev() {
            let right_p = *bytes.get(pos[j]+1).unwrap() as u64 - 48;
            let right_m = val[j+1] / right_p;
            ans = std::cmp::max(
                ans,
                left + left_m * (left_p + tot + right_p) * right_m + right);

            tot -= val[j];
            right += val[j+1];
        }

        left += val[i];
    }
    println!("{}", ans);
}


S=raw_input()
prec=-1
sol=eval(S)

for i in range(len(S)):
	if(S[i]!='*'):
		continue

	if(prec==-1):
		sol=max(sol,eval(str(eval(S[:i])) + S[i:]))
	else:
		sol=max(sol,eval(S[:prec+1] + str(eval(S[prec+1:i])) + S[i:]))
	prec=i

if(prec!=-1):
	sol=max(sol,eval(S[:prec] + str(eval(S[prec+1:])) ))

print sol


S=raw_input()
prec=-1
sol=eval(S)

for i in range(0,len(S),2):
	for j in range(i+2,len(S),2):
		sol=max(sol,eval(S[:i] + "(" + S[i:j+1] + ")" + S[j+1:]))
print sol


S="1*" +  raw_input() + "*1"
prec=-1
sol=eval(S)

for i in range(2,len(S)-2,2):
	if(S[i-1]!='*'):continue
	for j in range(i+2,len(S)-2,2):
		if(S[j+1]!='*'):  continue
		sol=max(sol,eval(S[:i] + "(" + S[i:j+1] + ")" + S[j+1:]))
print sol


S=raw_input()
prec=-1
sol=eval(S)

for i in range(len(S)):
	if(S[i]!='*'):
		continue

	if(prec==-1):
		sol=max(sol,eval(str(eval(S[:i])) + S[i:]))
	else:
		sol=max(sol,eval(S[:prec+1] + str(eval(S[prec+1:i])) + S[i:]))
	prec=i

if(prec!=-1):
	sol=max(sol,eval(S[:prec+1] + str(eval(S[prec+1:])) ))

print sol


exp = list(raw_input().split()[0])
ans = 0
index = [-1]
for i in xrange(1, len(exp), 2):
    if exp[i] == "*":
        index.append(i)
index.append(len(exp))
for i in xrange(len(index)-1):
    exp.insert(index[i]+1, "(")
    for j in xrange(i+1, len(index)):
        exp.insert(index[j]+1, ")")
        ans = max(ans, eval("".join(exp)))
        exp.pop(index[j]+1)
    exp.pop(index[i]+1)
print ans


i = raw_input()
i = '  ' + i + '  '
ans = eval(i)
if(len(i)==3):
    print eval(i)
else:
    for x in range(1,(len(i)-2)/2):
        for y in range(x+1,(len(i)-2)/2 + 1):
            if(i[2*x-1] == '*' or i[2*y-1] == '*'):
                ans = max(ans,eval(i[0:x*2] + str(eval(i[2*x:2*y-1])) + i[2*y-1:]))
    print ans


i = raw_input()
if(len(i)==3):
    print eval(i)
else:
    ans = max(eval(str(eval(i[0:3])) + i[3:]) , eval(i[:-3] + str(eval(i[-3:]))))
    for x in range(0,(len(i)/2)):
        for y in range(x+1,len(i)/2 + 1):
            ans = max(ans,eval(i[0:x*2] + str(eval(i[2*x:2*y+1])) + i[2*y+1:]))
    print ans


e = raw_input()

n, result = len(e), eval(e)
for i in xrange(-1, n):
    if i == -1 or e[i] == '*':
        for j in xrange(i + 1, n + 1):
            if j == n or e[j] == '*':
                result = max(result, eval(e[:i + 1] + '(' + e[i + 1:j] + ')' + e[j:]))
print(result)


import sys, os

def solve():
    s = raw_input()
    res = eval(s)
    for l in xrange(-1, len(s)):
        if s[l] == '*' or l == -1:
            for r in xrange(l + 2, len(s) + 1, 2):
                if r == len(s) or s[r] == '*':
                    temp = s[:l + 1] + '(' + s[l + 1 : r] + ')' + s[r : ]
                    try: res = max(res, eval(temp))
                    except: pass
    print(res)

# def prt(l): return print(' '.join(l))
# def rv(): return map(int, input().split())
# def rl(n): return [list(map(int, input().split())) for _ in range(n)]
if os.path.exists("test.txt"): sys.stdin = open("test.txt")
solve()


from fractions import gcd
import sys

def solve():
    s = raw_input()
    res = eval(s)
    for l in xrange(-1, len(s)):
        if s[l] == '*' or l == -1:
            for r in xrange(l + 2, len(s) + 1, 2):
                if r == len(s) or s[r] == '*':
                    temp = s[:l + 1] + '(' + s[l + 1 : r] + ')' + s[r : ]
                    try: res = max(res, eval(temp))
                    except: pass
    print(res)

if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()


s=str(raw_input())

arr=[0,len(s)+1]

for i in range(0,len(s)):
    if(s[i]=='*'):
        arr.append(i)
arr.sort();
minx=0
for k1 in range(0,len(arr)):
    if(arr[k1]==0):
        test='('
    else:
        test=s[0:arr[k1]+1]+'('
    for k2 in range(k1+1,len(arr)):
        tt=test
        if(arr[k1]==0):
            tt=tt+s[arr[k1]:arr[k2]]+')'+s[arr[k2]:len(s)]
        else:
            tt=tt+s[arr[k1]+1:arr[k2]]+')'+s[arr[k2]:len(s)]
        exec("a="+tt)
        if(a>minx):
            minx=a;
        #print k1,k2
        #print tt

print minx


# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = raw_input()
n = len(s)
pos = []
for i in xrange(n):
    if s[i] == "*":
        pos.append(i)

m = len(pos)
ans = eval(s)
for i in xrange(m):
    for j in xrange(pos[i]):
        if not s[j].isdigit(): continue
        t = s[:j] + "(" + s[j:pos[i]] + ")" + s[pos[i]:]
        ans = max(ans, eval(t))
    for j in xrange(pos[i] + 1, n):
        if not s[j].isdigit(): continue
        t = s[:pos[i] + 1] + "(" + s[pos[i] + 1:j + 1] + ")" + s[j + 1:]
        ans = max(ans, eval(t))
print ans


# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = "*" + raw_input() + "*"
n = len(s)
pos = []
for i in xrange(n):
    if s[i] == "*":
        pos.append(i)

m = len(pos)
ans = eval(s[1:-1])
for i in xrange(m):
    p = pos[i]
    for j in xrange(i + 1, m):
        q = pos[j]
        t = s[1:p + 1] + "(" + s[p + 1:q] + ")" + s[q:-1]
        ans = max(ans, eval(t))
print ans


# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = "*" + raw_input() + "*"
n = len(s)
pos = []
for i in xrange(n):
    if s[i] == "*":
        pos.append(i)

m = len(pos)
ans = eval(s[1:-1])
for i in xrange(m):
    p = pos[i]
    for j in xrange(i + 1, m):
        q = pos[j]
        t = s[1:p + 1] + "(" + s[p + 1:q] + ")" + s[q:-1]
        print t
        ans = max(ans, eval(t))
print ans


# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

s = raw_input()
n = len(s)
pos = []
for i in xrange(n):
    if s[i].isdigit():
        pos.append(i)

m = len(pos)
ans = 0
for i in xrange(m):
    for j in xrange(i + 1, m):
        t = s[:pos[i]] + "(" + s[pos[i]:pos[j] + 1] + ")" + s[pos[j] + 1:]
        ans = max(ans, eval(t))
print ans


import sys
import re

exp_str = raw_input()

ps = [-1] + [m.start() for m in re.finditer('\*', exp_str)] + [len(exp_str)]

if not ps:
    print eval(exp_str)
else:
    ans = eval(exp_str)
    n = len(ps)
    for i in xrange(n):
        for j in xrange(i + 1, n):
            ii = ps[i]
            jj = ps[j]
            s = exp_str[:ii + 1] + "(" + exp_str[ii + 1: jj] + ")" + exp_str[jj:]
            ans = max(ans, eval(s))

    print ans


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] == '*':
        d.append(i)
d.append(len(s))
mx = -1488
for i in xrange(len(d)):
    for j in xrange(i + 2, len(d)):
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] in ('+', '*'):
        d.append(i)
d.append(len(s))
mx = -1488
for i in xrange(len(d)):
    for j in xrange(i + 2, len(d)):
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] in ('+', '*'):
        d.append(i)
d.append(len(s))
mx = eval(s)
for i in xrange(len(d)):
    if s[d[i + 1]] == '*':
        continue
    for j in xrange(i + 2, len(d)):
        if s[d[j - 1]] == '*':
            continue
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] in ('+', '*'):
        d.append(i)
d.append(len(s))
mx = eval(s)
for i in xrange(len(d)):
    if d[i + 1] == '*':
        continue
    for j in xrange(i + 2, len(d)):
        if s[d[j - 1]] == '*':
            continue
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] == '*':
        d.append(i)
d.append(len(s))
mx = eval(s)
for i in xrange(len(d) - 1):
    for j in xrange(i + 1, len(d)):
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


s = raw_input()
d = [-1]
for i in xrange(len(s)):
    if s[i] in ('+', '*'):
        d.append(i)
d.append(len(s))
mx = eval(s)
for i in xrange(len(d)):
    for j in xrange(i + 2, len(d)):
        if s[d[j - 1]] == '*' or d[i + 1] == '*':
            continue
        inside = eval(s[d[i] + 1: d[j]])
        mx = max(mx, eval(s[: d[i] + 1] + str(inside) + s[d[j]:]))
print mx


#include <bits/stdc++.h>
#define PROC int main(){ios;
#pragma GCC optimize ("-O3")
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,0,n-1)
#define pf         printf

vector<ll> V, G;
int ans = 0; int n, k;
#define set(i) (1LL<<i)

void bron_kerbosch(ll X, ll A, ll B){
	if ((A == 0LL) && (B == 0LL)) {V.push_back(X);return;}
	int u; REP(i, n) if ((A|B) & set(i)) {u=i;break;}
	REP(i, n)
		if ((A&~G[u]) & set(i)) {
			bron_kerbosch(X | set(i), A & G[i], B & G[i]);
			A -= set(i); B |= set(i);
		}
}

PROC { /*==========================================*/

cin >> n >> k; G.resize(n, 0);
REP(i, n) REP(j, n) {
	int t; cin >> t;
	if (t == 1) G[i] |= set(j);
}

bron_kerbosch(0, ~0LL, 0);
VEC(u, V) ans = max(__builtin_popcountll(u), ans);

pf("%0.100f", 0.5*k*k*(ans-1)/ans);

}} /*PROC==========================================*/

/*
10 158
0 0 0 0 0 0 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 1 1 1 0
0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 1 1 0 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0
0 1 1 0 0 1 0 1 0 0
1 0 0 0 0 0 0 0 0 0
*/


#include <bits/stdc++.h>
#define PROC int main(){ios;
#pragma GCC optimize ("-O3")
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,0,n-1)
#define pf         printf

int n, k; vector<ll> V, G;
#define set(i) (1LL<<i)

void bron_kerbosch(ll R, ll P, ll X){
	if ((P == 0LL) && (X == 0LL)) {V.push_back(R);return;}
	int u; REP(i, n) if ((P|X) & set(i)) {u=i;break;}
	REP(i, n)
		if ((P&~G[u]) & set(i)) {
			bron_kerbosch(R | set(i), P & G[i], X & G[i]);
			P -= set(i); X |= set(i);
		}
}

PROC { /*==========================================*/

cin >> n >> k; G.resize(n, 0);
REP(i, n) REP(j, n) {
	int t; cin >> t;
	if (t == 1) G[i] |= set(j);
}

bron_kerbosch(0, ~0LL, 0);

int ans = 2;
VEC(u, V) {
	ll x = __builtin_popcountll(u);
	if (x > ans) ans = x;
}

if (n == 1) ans = 1;
pf("%0.100f", 0.5*k*k*(ans-1)/ans);

}} /*PROC==========================================*/

/*
10 158
0 0 0 0 0 0 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 1 1 1 0
0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 1 1 0 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0
0 1 1 0 0 1 0 1 0 0
1 0 0 0 0 0 0 0 0 0
*/

/*
5 21
0 1 1 1 1
1 0 1 1 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 0
*/


#include <bits/stdc++.h>
#define PROC int main(){ios;
#pragma GCC optimize ("-O3")
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,0,n-1)
#define pf         printf

int n, k; vector<ll> V, G;
#define set(i) (1LL<<i)

void bron_kerbosch(ll R, ll P, ll X){
	if ((P == 0LL) && (X == 0LL)) {V.push_back(R);return;}
	int u; REP(i, n) if ((P|X) & set(i)) {u=i;break;}
	REP(i, n)
		if ((P&~G[u]) & set(i)) {
			bron_kerbosch(R | set(i), P & G[i], X & G[i]);
			P -= set(i); X |= set(i);
		}
}

PROC { /*==========================================*/

cin >> n >> k; G.resize(n, 0);
REP(i, n) REP(j, n) {
	int t; cin >> t;
	if (t == 1) G[i] |= set(j);
}

bron_kerbosch(0, ~0LL, 0);

int ans = 0;
VEC(u, V) {
	ll x = __builtin_popcountll(u);
	if (x > ans) ans = x;
}

pf("%0.100f", 0.5*k*k*(ans-1)/ans);

}} /*PROC==========================================*/

/*
10 158
0 0 0 0 0 0 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 1 1 1 0
0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 1 1 0 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0
0 1 1 0 0 1 0 1 0 0
1 0 0 0 0 0 0 0 0 0
*/


#include <bits/stdc++.h>
#define PROC int main(){ios;
#pragma GCC optimize ("-O3")
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,1,n)
#define pf         printf

int n, k; vi V, G;
#define set(i) (1LL<<i)

void bron_kerbosch(ll R, ll P, ll X){
	if ((P == 0LL) && (X == 0LL)) {V.push_back(R);return;}
	int u = 1; REP(i, n) if ((P|X) & set(u)) {u=i;break;}
	REP(i, n)
		if ((P&~G[u]) & set(i)) {
			bron_kerbosch(R | set(i), P & G[i], X & G[i]);
			P -= set(i); X |= set(i);
		}
}

PROC { /*==========================================*/

cin >> n >> k; G.resize(n, 0);
REP(i, n) REP(j, n) {
	int t; cin >> t;
	if (t == 1) G[i] |= set(j);
}

bron_kerbosch(0, ~0LL, 0);

int ans = 0;
VEC(u, V) {
	int x = __builtin_popcount(u);
	if (x > ans) ans = x;
}

pf("%f", 0.5*k*k*(ans-1)/ans);

}} /*PROC==========================================*/

/*
10 158
0 0 0 0 0 0 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 1 1 1 0
0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 1 1 0 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0
0 1 1 0 0 1 0 1 0 0
1 0 0 0 0 0 0 0 0 0
*/


#include <bits/stdc++.h>
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,1,n)
#define pf         printf

int n, k, w = 0; float p;
float T[40+2]; int M[40+2][40+2];
vi G[40+2]; vector<pii> R;
#define pb push_back
#define num(x)((int)(x).size())

/*=[MAIN]*/int main(){ios;

cin >> n >> k;
REP(i, n) REP(j, n) {
	int t; cin >> t; if (t == 1) { G[i].pb(j); w++; }
}

REP(i, n) R.pb({num(G[i]), i});
sort(R.rbegin(), R.rend());

VEC(h, R) {
	T[h.second] = (float)k*(float)(h.first)/(float)w;
	// pf("%d: %d --> %f\n", h.first, h.second, T[h.second]);
}

REP(i, n) {
	float s = 0;
	VEC(j, G[i]) {
		if (M[i][j] != 1)
			s += T[i] * T[j];
		M[i][j] = 1, M[j][i] = 1;
	}
	p += s;
}

pf("%f\n", p);

}/*[MAIN]*/

/*
4 4
0 1 0 1
1 0 1 0
0 1 0 1
1 0 1 0
*/


#include <bits/stdc++.h>
#define PROC int main(){ios;
#pragma GCC optimize ("-O3")
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,1,n)
#define pf         printf

int n, k; vi V, G;
#define set(i) (1LL<<i)

void bron_kerbosch(ll R, ll P, ll X){
	if ((P == 0LL) && (X == 0LL)) {V.push_back(R);return;}
	int u = 1; REP(i, n) if ((P|X) & set(u)) {u=i;break;}
	REP(i, n)
		if ((P&~G[u]) & set(i)) {
			bron_kerbosch(R | set(i), P & G[i], X & G[i]);
			P -= set(i); X |= set(i);
		}
}

PROC { /*==========================================*/

cin >> n >> k; G.resize(n, 0);
REP(i, n) REP(j, n) {
	int t; cin >> t;
	if (t == 1) G[i] |= set(j);
}

bron_kerbosch(0, ~0LL, 0);

int ans = 2;
VEC(u, V) {
	int x = __builtin_popcount(u);
	if (x > ans) ans = x;
}

if (n == 1) ans = 1;
pf("%f", 0.5*k*k*(ans-1)/ans);

}} /*PROC==========================================*/

/*
10 158
0 0 0 0 0 0 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 1 1 1 0
0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 1 1 0 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0
0 1 1 0 0 1 0 1 0 0
1 0 0 0 0 0 0 0 0 0
*/


#include <bits/stdc++.h>
#define PROC int main(){ios;
#pragma GCC optimize ("-O3")
using namespace std;typedef long long ll;
typedef pair<int,int>pii;typedef vector<int>vi;
#define ios        ios::sync_with_stdio(0),cin.tie(0)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,a,b) for(int i=a;i>=b;--i)
#define VEC(i,v)   for(auto&i:v)
#define REP(i,n)   FOR(i,1,n)
#define pf         printf

int n, k; vi V, G;
#define set(i) (1LL<<i)

void bron_kerbosch(ll R, ll P, ll X){
	if ((P == 0LL) && (X == 0LL)) {V.push_back(R);return;}
	int u = 1; REP(i, n) if ((P|X) & set(u)) {u=i;break;}
	REP(i, n)
		if ((P&~G[u]) & set(i)) {
			bron_kerbosch(R | set(i), P & G[i], X & G[i]);
			P -= set(i); X |= set(i);
		}
}

PROC { /*==========================================*/

cin >> n >> k; G.resize(n, 0);
REP(i, n) REP(j, n) {
	int t; cin >> t;
	if (t == 1) G[i] |= set(j);
}

bron_kerbosch(0, ~0LL, 0);

int ans = 2;
VEC(u, V) {
	int x = __builtin_popcount(u);
	if (x > ans) ans = x;
}

pf("%f", 0.5*k*k*(ans-1)/ans);

}} /*PROC==========================================*/

/*
10 158
0 0 0 0 0 0 0 1 0 1
0 0 1 0 1 0 1 0 1 0
0 1 0 0 0 0 1 1 1 0
0 0 0 0 1 0 0 0 0 0
0 1 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0
0 1 1 0 0 0 0 0 0 0
1 0 1 0 0 1 0 0 1 0
0 1 1 0 0 1 0 1 0 0
1 0 0 0 0 0 0 0 0 0
*/


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
using namespace std;
const int MaxN=50;
int n,k,G[MaxN][MaxN];
int ans[MaxN],lastans,ch[MaxN];
int maxn;
bool Dfs(int x,int num) {
	ch[num]=x;
	if (num>lastans) {
		lastans=num;
		return true;
	}
	for (int y=x+1;y<=n;y++) {
		if (!G[x][y]) continue;
		if (num+ans[y]<=lastans) continue;
		int flag=1;
		for (int i=1;i<=num;i++)
			if (!G[ch[i]][y]) {
				flag=0;
				break;
			}
		if (flag&&Dfs(y,num+1)) return true;
	}
	return false;
}
void Solve() {
	lastans=0;
	for (int i=n;i>=1;i--) {
		Dfs(i,1);
		ans[i]=lastans;
		maxn=max(maxn,lastans);
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
		scanf("%d",&G[i][j]);
	Solve();
	printf("%.6lf\n",(double)(1.0*(maxn-1)*k*k)/(2.0*maxn));
	return 0;
}


#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
using namespace std;
const int MaxN=50;
int n,k,G[MaxN][MaxN];
int ans[MaxN],lastans,ch[MaxN];
int maxn;
bool Dfs(int x,int num) {
	ch[num]=x;
	if (num>lastans) {
		lastans=num;
		return true;
	}
	for (int y=x+1;y<=n;y++) {
		if (!G[x][y]) continue;
		if (num+ans[y]<=num) continue;
		int flag=1;
		for (int i=1;i<=num;i++)
			if (!G[ch[i]][y]) {
				flag=0;
				break;
			}
		if (flag&&Dfs(y,num+1)) return true;
	}
	return false;
}
void Solve() {
	lastans=0;
	for (int i=n;i>=1;i--) {
		Dfs(i,1);
		ans[i]=lastans;
		maxn=max(maxn,lastans);
	}
}
int main() {
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)
	for (int j=1;j<=n;j++)
		scanf("%d",&G[i][j]);
	Solve();
	printf("%.6lf\n",(double)(1.0*(maxn-1)*k*k)/(2.0*maxn));
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

bool edg[45][45];
bool used[45];
int cnt=0,bst=0,n;

void bc(int i) {
	if(i >= n) {
		bst = max(bst,cnt);
		return;
	}
	bool flag = false;
	rep(j,0,i) {
		if(i == j) continue;
		if(used[j] && !edg[i][j]) {
			flag = true;
			break;
		}
	}
	if(!flag) { // can use
		used[i] = true;
		cnt++;
		bc(i+1);
		used[i] = false;
		cnt--;
	}
	bc(i+1);
}

int main() {
	cin.sync_with_stdio(false);
	double e;
	cin >> n >> e;
	rep(i,0,n) rep(a,0,n) cin >> edg[i][a];
	bc(0);
	double be = bst;
	double edges = bst*(bst-1)/2;
	double split = e/be;
	cout << setprecision(16) << fixed << split*split*edges << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

bool edg[45][45];
bool used[45];
int cnt=0,bst=0,n;

void bc(int i) {
	if(i >= n) {
		bst = max(bst,cnt);
		return;
	}
	bool flag = false;
	rep(j,0,n) {
		if(i == j) continue;
		if(used[j] && !edg[i][j]) {
			flag = true;
			break;
		}
	}
	if(!flag) { // can use
		used[i] = true;
		cnt++;
		bc(i+1);
		used[i] = false;
		cnt--;
	}
	bc(i+1);
}

int main() {
	cin.sync_with_stdio(false);
	double e;
	cin >> n >> e;
	rep(i,0,n) rep(a,0,n) cin >> edg[i][a];
	bc(0);
	double be = bst;
	double edges = bst*(bst-1)/2;
	double split = e/be;
	cout << setprecision(16) << fixed << split*split*edges << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

bool edg[45][45];
bool used[45];
int cnt=0,bst=0,n;

void bc(int i) {
	if(i >= n) {
		bst = max(bst,cnt);
		return;
	}
	bool flag = false;
	rep(j,0,i) {
		if(used[j] && !edg[i][j]) {
			flag = true;
			break;
		}
	}
	if(!flag) { // can use
		used[i] = true;
		cnt++;
		bc(i+1);
		cnt--;
	}
	if(cnt+n-i > bst) {
		used[i] = false;
		bc(i+1);
	}
}

int main() {
	cin.sync_with_stdio(false);
	double e;
	cin >> n >> e;
	rep(i,0,n) rep(a,0,n) cin >> edg[i][a];
	bc(0);
	double be = bst;
	double edges = bst*(bst-1)/2;
	double split = e/be;
	cout << setprecision(16) << fixed << split*split*edges << endl;
	return 0;
}


#include <cstdio>
#include <vector>

int tab[47][47];
std::vector<int> wybrane;
int sr, ter;
int maxi[1 << 21];
int wyn = 0;
int N;

void adam(int a) {
    if (a >= sr) {
        maxi[ter] = (int) wybrane.size();
        return;
    }
    bool moge = true;
    for (auto it : wybrane)
        moge &= tab[it][a];
    if (moge) {
        ter ^= (1 << a);
        wybrane.push_back(a);
        adam(a + 1);
        ter ^= (1 << a);
        wybrane.pop_back();
    }
    adam(a + 1);
}

void adam2(int a) {
    if (a >= N) {
        int moge = (1 << sr) - 1;
        for (int i = 0; i < sr; i++) {
            int wsp = 0;
            for (auto it : wybrane)
                if (!tab[it][i])
                    wsp = (1 << i);
            moge ^= wsp;
        }
        wyn = std::max(wyn, (int) wybrane.size() + maxi[moge]);
        return;
    }
    bool moge = true;
    for (auto it : wybrane)
        moge &= tab[it][a];
    if (moge) {
        wybrane.push_back(a);
        adam2(a + 1);
        wybrane.pop_back();
    }
    adam2(a + 1);
}

int main() {
    int K;
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++)
        for (int w = 0; w < N; w++)
            scanf("%d", &tab[i][w]);
    sr = N / 2;
    adam(0);
    int kon = 1 << sr;
    for (int i = 0; i < kon; i++)
        for (int w = 0; w < sr; w++)
            if (i & (1 << w))
                maxi[i] = std::max(maxi[i], maxi[i ^ (i << w)]);
    adam2(sr);
    double wsp = double(K) / wyn;
    wsp *= wsp;
    printf("%lf", wsp * wyn * (wyn - 1) / 2);
    return 0;
}


#include <cstdio>
#include <vector>

int tab[47][47];
std::vector<int> wybrane;
int sr, ter;
int maxi[1 << 21];
int wyn = 0;
int N;

void adam(int a) {
    if (a >= sr) {
        maxi[ter] = (int) wybrane.size();
        return;
    }
    bool moge = true;
    for (auto it : wybrane)
        moge &= tab[it][a];
    if (moge) {
        ter ^= (1 << a);
        wybrane.push_back(a);
        adam(a + 1);
        ter ^= (1 << a);
        wybrane.pop_back();
    }
    adam(a + 1);
}

void adam2(int a) {
    if (a >= N) {
        int moge = (1 << sr) - 1;
        for (int i = 0; i < sr; i++) {
            int wsp = 0;
            for (auto it : wybrane)
                if (!tab[it][i])
                    wsp = (1 << i);
            moge ^= wsp;
        }
        wyn = std::max(wyn, (int) wybrane.size() + maxi[moge]);
        return;
    }
    bool moge = true;
    for (auto it : wybrane)
        moge &= tab[it][a];
    if (moge) {
        wybrane.push_back(a);
        adam2(a + 1);
        wybrane.pop_back();
    }
    adam2(a + 1);
}

int main() {
    int K;
    scanf("%d%d", &N, &K);
    for (int i = 0; i < N; i++)
        for (int w = 0; w < N; w++)
            scanf("%d", &tab[i][w]);
    sr = N / 2;
    adam(0);
    int kon = 1 << sr;
    for (int i = 0; i < kon; i++)
        for (int w = 0; w < sr; w++)
            if ((i & (1 << w)))
                maxi[i] = std::max(maxi[i], maxi[i ^ (1 << w)]);
    adam2(sr);
    double wsp = double(K) / wyn;
    wsp *= wsp;
    printf("%lf", wsp * wyn * (wyn - 1) / 2);
//    printf("%d", wyn);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
void dfs(int node){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	for (int i=node+1;i<n;i++){
		bool flag = true;
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
void dfs(int node){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
int d[MAX];
int ac;
#define random(a,b) (a+rand()%((b)-(a)+1))
void dfs(int node,bool fffff){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}
		if (fffff&&d[i]<=ans+ac){
			int xxx = random(1,10);
			if (xxx<ac){
				continue;
			}
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i,fffff);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	bool fff = false;
	if (n>=35){
		fff = true;
	}
	if (n>=39){
		ac =3;
	}else{
		ac=2;
	}
	dfs(-1,fff);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
int d[MAX];
#define random(a,b) (a+rand()%((b)-(a)+1))
void dfs(int node,bool fffff){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}
		if (fffff&&d[i]<=ans+3){
			int xxx = random(1,10);
			if (xxx<3){
				continue;
			}
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i,fffff);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	bool fff = false;
	if (n>=35){
		fff = true;
	}
	dfs(-1,fff);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
void dfs(int node){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-nonde-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
int d[MAX];
#define random(a,b) (a+rand()%((b)-(a)+1))
void dfs(int node){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}else if (d[i]<=ans+3){
			int xxx = random(1,10);
			if (xxx<3){
				continue;
			}
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
vector<int> inMass;
int d[MAX];
int ac;
#define random(a,b) (a+rand()%((b)-(a)+1))
void dfs(int node){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.push_back(i);
			dfs(i);
			inMass.pop_back();
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
void dfs(int node){
	ans = max(ans,(int)inMass.size());
	for (int i=node+1;i<n;i++){
		bool flag = true;
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i+1);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
int d[MAX];
int ac;
#define random(a,b) (a+rand()%((b)-(a)+1))
void dfs(int node,bool fffff){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}
		if (fffff&&d[i]<=ans+1){
			int xxx = random(1,100);
			if (xxx<20){
				continue;
			}
		}else if (fffff&&d[i]<=ans+2){
			int xxx = random(1,100);
			if (xxx<10){
				continue;
			}
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i,fffff);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	bool fff = false;
	if (n>=35){
		fff = true;
	}
	dfs(-1,fff);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
int d[MAX];
#define random(a,b) (a+rand()%((b)-(a)+1))
void dfs(int node,bool fffff){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}
		if (fffff&&d[i]<=ans+2){
			int xxx = random(1,10);
			if (xxx<2){
				continue;
			}
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i,fffff);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	bool fff = false;
	if (n>=35){
		fff = true;
	}
	dfs(-1,fff);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int MAX = 100;
bool mp[MAX][MAX];
int n,k;
int ans;
set<int> inMass;
int d[MAX];
void dfs(int node){
//	cout<<"dfs("<<node<<")="<<inMass.size();
	ans = max(ans,(int)inMass.size());
	if (ans>=inMass.size()+n-node-1){
		return;
	}
	for (int i=node+1;i<n;i++){
		bool flag = true;
		if (d[i]<=ans){
			continue;
		}
		for (int temp:inMass){
			if (!mp[temp][i]){
				flag = false;
				break;
			}
		}
		if (flag){
			inMass.insert(i);
			dfs(i);
			inMass.erase(i);
		}
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			int temp;
			scanf("%d",&temp);
			mp[i][j] = temp;
			d[i]++;
		}
	}
	dfs(-1);
	double res = 1.0*(ans-1)/2.0/ans*k*k;
	printf("%.9f",res);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int n,k;
int a[50][50],check[50];
vector<int> graph[50];
int main(){
    scanf("%d%d",&n,&k);
    int i,j;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            scanf("%d",&a[i][j]);
            if(a[i][j]) graph[i].push_back(j);
        }
    }
    queue<int> q;
    int ans = 0;
    for(i=1;i<=n;i++){
        if(!check[i]){
            q.push(i);
            int cnt = 0;
            check[i] = 1;
            while(!q.empty()){
                int x = q.front();
                cnt++;
                q.pop();
                for(j=0;j<graph[x].size();j++){
                    int y = graph[x][j];
                    if(!check[y]){
                        q.push(y);
                        check[y] = 1;
                    }
                }
            }
            if(cnt>1) ans += cnt;
        }
    }
    double answer = 0.0;
    for(i=1;i<=n;i++){
        for(j=i+1;j<=n;j++){
            if(a[i][j]){
                answer += pow((double)k/(double)ans,2);
            }
        }
    }
    printf("%lf",answer);
    return 0;
}


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

const int N = 1 << 20;
int bit[N];
int dp[N];
long long a[50];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    if (n < 2) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        int x;
        for (int j = 0; j < n; j++) {
            scanf("%d", &x);
            a[i] |= (1LL << x);
        }
        a[i] |= (1LL << i);
    }
    int mid = n >> 1;
    for (int i = 0; i < mid; i++) dp[1 << i] = 1;
    for (int i = 1; i < (1 << mid); i++) {
        for (int j = 0; j < mid; j++) {
            if (i & (1 << j)) continue;
            int mask = a[j] & i;
            dp[i | (1 << j)] = max(dp[i], dp[mask] + 1);
            break;
        }
    }
    for (int i = 1; i < N; i++) bit[i] = bit[i >> 1] + (i & 1);
    int ans = dp[(1 << mid) - 1];
    for (int i = 1; i < (1 << (n - mid)); i++) {
        long long state = 0;
        for (int j = 0; j < n - mid; j++)
            if (i & (1 << j)) state |= a[j + mid];
        bool flag = false;
        for (int j = 0; j < n - mid; j++)
            if (i & (1 << j)) state &= a[j + mid];
        if ((state & (i << mid)) != (i << mid)) continue;
        ans = max(ans, bit[i] + dp[state >> mid]);
    }
    printf("%.20lf\n", (1.0 * m * m / ans / ans) * ans * (ans - 1) / 2);
    return 0;
}


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

const int N = 1 << 20;
int bit[N];
int dp[N];
long long a[50];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    if (n < 2) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        int x;
        for (int j = 0; j < n; j++) {
            scanf("%d", &x);
            if (x) a[i] |= (1LL << j);
        }
        a[i] |= (1LL << i);
    }
    int mid = n >> 1;
    for (int i = 0; i < mid; i++) dp[1 << i] = 1;
    for (int i = 1; i < (1 << mid); i++) {
        for (int j = 0; j < mid; j++) {
            if (i & (1 << j)) continue;
            int mask = a[j] & i;
            if (mask == (i | (1 << j))) dp[i | (1 << j)] = dp[i] + 1;
            else dp[i | (1 << j)] = max(dp[i], dp[mask] + 1);
        }
    }
    for (int i = 1; i < N; i++) bit[i] = bit[i >> 1] + (i & 1);
    int ans = dp[(1 << mid) - 1];
    for (long long i = 1; i < (1 << (n - mid)); i++) {
        long long state = 0;
        for (int j = 0; j < n - mid; j++)
            if (i & (1 << j)) state |= a[j + mid];
        bool flag = false;
        for (int j = 0; j < n - mid; j++)
            if (i & (1 << j)) state &= a[j + mid];
        if ((state & (i << mid)) != (i << mid)) continue;
        ans = max(ans, bit[i] + dp[state & ((1 << mid) - 1)]);
    }
    printf("%.20lf\n", (1.0 * m * m / ans / ans) * ans * (ans - 1) / 2);
    return 0;
}


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

const int N = 1 << 20;
int bit[N];
int dp[N];
long long a[50];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    if (n < 2) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        int x;
        for (int j = 0; j < n; j++) {
            scanf("%d", &x);
            if (x) a[i] |= (1LL << j);
        }
        a[i] |= (1LL << i);
    }
    int mid = n >> 1;
    for (int i = 0; i < mid; i++) dp[1 << i] = 1;
    for (int i = 1; i < (1 << mid); i++) {
        for (int j = 0; j < mid; j++) {
            if (i & (1 << j)) continue;
            int mask = a[j] & i;
            dp[i | (1 << j)] = max(dp[i], dp[mask] + 1);
            break;
        }
    }
    for (int i = 1; i < N; i++) bit[i] = bit[i >> 1] + (i & 1);
    int ans = dp[(1 << mid) - 1];
    for (long long i = 1; i < (1 << (n - mid)); i++) {
        long long state = 0;
        for (int j = 0; j < n - mid; j++)
            if (i & (1 << j)) state |= a[j + mid];
        bool flag = false;
        for (int j = 0; j < n - mid; j++)
            if (i & (1 << j)) state &= a[j + mid];
        if ((state & (i << mid)) != (i << mid)) continue;
        ans = max(ans, bit[i] + dp[state & ((1 << mid) - 1)]);
    }
    printf("%.20lf\n", (1.0 * m * m / ans / ans) * ans * (ans - 1) / 2);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

LL  e[55],
    p[55];

int main() {
    srand(998244353);
    LL  n = 0,
        m = 0,
        res = 0,
        T = 5e3,
        num = 0;

    cin>>n>>m;
    for(int i = 0; i<n; ++i) {
        for(int j = 0; j<n; ++j) {
            cin>>num;
            e[i] |= num<<j;
        }
    }

    for(LL i = 0; i<n; ++i) {
        p[i] = i;
    }

    while(T--) {
        random_shuffle(p,p+n);
        LL  cur = (1LL<<n)-1;
        LL  sum = 0;
        for(int i = 0; i<n; ++i) {
            if((cur>>p[i]) &1) {
                cur &= e[p[i]];
                ++sum;
            }
        }

        res = max(res, sum);
    }

    printf("%.10lf", 0.5*m*m*(res-1)/res);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

LL  e[55],
    p[55];

int main() {
    srand(998244353);
    LL  n = 0,
        m = 0,
        res = 0,
        T = 5e3,
        num = 0;

    cin>>n>>m;
    for(int i = 0; i<n; ++i) {
        for(int j = 0; j<n; ++j) {
            cin>>num;
            e[i] |= num<<j;
        }
    }

    for(LL i = 0; i<n; ++i) {
        p[i] = i;
    }

    while(T--) {
        random_shuffle(p,p+n);
        LL  cur = (1<<n)-1;
        LL  sum = 0;
        for(int i = 0; i<n; ++i) {
            if((cur>>p[i]) &1) {
                cur &= e[p[i]];
                ++sum;
            }
        }

        res = max(res, sum);
    }

    printf("%.10lf", 0.5*m*m*(res-1)/res);
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long LL;

LL  e[55],
    p[55];

int main() {
    LL  n = 0,
        m = 0,
        res = 0,
        T = 5e3,
        num = 0;

    cin>>n>>m;
    for(int i = 0; i<n; ++i) {
        for(int j = 0; j<m; ++j) {
            cin>>num;
            e[i] |= num<<j;
        }
    }

    for(LL i = 0; i<n; ++i) {
        p[i] = i;
    }

    while(T--) {
        random_shuffle(p,p+n);
        LL  cur = (1<<n)-1;
        LL  sum = 0;
        for(int i = 0; i<n; ++i) {
            if((cur>>p[i]) &1) {
                cur &= e[p[i]];
                ++sum;
            }
        }

        res = max(res, sum);
    }

    printf("%.10lf", 0.5*m*m*(res-1)/res);
    return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define N 42
#define LL long long
int n,m,ans=0;LL w[N];
void dfs(LL P,LL S,LL X)
{
	if(__builtin_popcountll(S|X|P)<=ans)return;if((!P)&&(!X))ans=max(ans,__builtin_popcountll(S|X));LL v;int x;
	while(P){v=P&(-P);x=__builtin_ctzll(v);X&=w[x];P^=v;dfs(P&w[x],S|v,X);X|=v;}
}
int main(){
	scanf("%d%d",&n,&m);int i,j,x;double v;
	for(i=0;i<n;i++)
	for(j=0;j<n;j++){scanf("%d",&x);if(x)w[i]|=(1ll<<j),w[j]|=(1ll<<i);}dfs((1ll<<n)-1,0,0);
	v=(1.0*m)/(1.0*ans);printf("%.12lf",v*v*ans*(ans-1)/2.0);return 0;
}


#include<iostream>
#include<cstdio>
using namespace std;
#define N 42
#define LL long long
int n,m,ans=0;LL w[N];
void dfs(LL P,LL S,LL X)
{
	if(__builtin_popcountll(S|P)<=ans)return;if((!P)&&(!X))ans=max(ans,__builtin_popcountll(S|X));LL v;int x;
	while(P){v=P&(-P);x=__builtin_ctzll(v);X&=w[x];P^=v;dfs(P&w[x],S|v,X);X|=v;}
}
int main(){
	scanf("%d%d",&n,&m);int i,j,x;double v;
	for(i=0;i<n;i++)
	for(j=0;j<n;j++){scanf("%d",&x);if(x)w[i]|=(1ll<<j),w[j]|=(1ll<<i);}dfs((1ll<<n)-1,0,0);
	v=(1.0*m)/(1.0*ans);printf("%.12lf",v*v*ans*(ans-1)/2.0);return 0;
}


//Hello. I'm Peter.
#include<cstdio>
#include<iostream>
#include<sstream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include<cctype>
#include<ctime>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double ld;
//const double pi=acos(-1.0);
//const double eps=1e-9;
#define peter cout<<"i am peter"<<endl
#define input freopen("data.txt","r",stdin)
#define randin srand((unsigned int)time(NULL))
#define INT (0x3f3f3f3f)*2
#define LL (0x3f3f3f3f3f3f3f3f)*2
#define gsize(a) (int)a.size()
#define len(a) (int)strlen(a)
#define slen(s) (int)s.length()
#define clr(a) memset(a,0,sizeof(a))
#define clr_true(a) memset(a,true,sizeof(a))
#define clr_queue(q) while(!q.empty()) q.pop()
#define clr_stack(s) while(!s.empty()) s.pop()
#define rep(i, a, b) for (int i = a; i < b; i++)
#define dep(i, a, b) for (int i = a; i > b; i--)
#define repin(i, a, b) for (int i = a; i <= b; i++)
#define depin(i, a, b) for (int i = a; i >= b; i--)
#define MAXN
#define N 100100
#define M
int n,m;
struct Interval{
    int l,r;
    bool up;
    int k,id;
}inter[N<<1];
inline bool comp1(const Interval a,const Interval b){
    if(a.r!=b.r) return a.r<b.r;
    else if(a.l!=b.l) return a.l>b.l;
    else return a.up>b.up;
}
int temp[N<<2],num_temp;
struct Segment_Tree{
    int left,right;
    int sum;
}tree[N<<4];
#define lch (id<<1)
#define rch (id<<1|1)
#define mid ((tree[id].left+tree[id].right)>>1)
inline void plant_tree(int id,int l,int r){
    tree[id].left=l,tree[id].right=r;
    tree[id].sum=0;
    if(l==r) return;
    plant_tree(lch,l,mid);
    plant_tree(rch,mid+1,r);
}
inline void update(int id,int pos,int v){
    if(tree[id].left==pos && pos==tree[id].right){
        tree[id].sum+=v;
        return;
    }
    if(pos<=mid) update(lch,pos,v);
    else update(rch,pos,v);
    tree[id].sum=tree[lch].sum+tree[rch].sum;
}
inline int query(int id,int l,int r){
    if(tree[id].left==l&&tree[id].right==r){
        return tree[id].sum;
    }
    if(r<=mid) return query(lch,l,r);
    else if(mid<l) return query(rch,l,r);
    else return query(lch,l,mid)+query(rch,mid+1,r);
}
inline int findk(int id,int aim){
    if(tree[id].left==tree[id].right){
        tree[id].sum-=1;
        return tree[id].left;
    }
    int res;
    if(tree[lch].sum>=aim) res=findk(lch,aim);
    else res=findk(rch,aim-tree[lch].sum);
    tree[id].sum=tree[lch].sum+tree[rch].sum;
    return res;
}
#define gbound(temp,x) (int)(lower_bound(temp+1,temp+1+num_temp,x)-temp)
vector<int>v[N<<2];
int part[N];
int main(){
    scanf("%d",&n);
    repin(i,1,n){
        scanf("%d%d",&inter[i].l,&inter[i].r);
        temp[++num_temp]=inter[i].l;
        temp[++num_temp]=inter[i].r;
        inter[i].up=true;
        inter[i].id=i;
    }
    scanf("%d",&m);
    repin(i,n+1,n+m){
        scanf("%d%d%d",&inter[i].l,&inter[i].r,&inter[i].k);
        temp[++num_temp]=inter[i].l;
        temp[++num_temp]=inter[i].r;
        inter[i].up=false;
        inter[i].id=i;
    }
    sort(inter+1,inter+1+n+m,comp1);
    sort(temp+1,temp+1+num_temp);
    num_temp=(int)(unique(temp+1,temp+1+num_temp)-(temp+1));
    plant_tree(1,0,num_temp);
    repin(i,1,n+m){
        if(inter[i].up){
            int k=gbound(temp,inter[i].l);
            update(1,k,1);
            v[k].push_back(inter[i].id);
        }
        else{
            while(inter[i].k){
                int k=gbound(temp,inter[i].l);
                int sum=query(1,0,k-1);
                if(sum==tree[1].sum) break;
                int w=findk(1,sum+1);
                int id=v[w].back();
                v[w].pop_back();
                part[id]=inter[i].id-n;
                inter[i].k--;
            }
        }
    }
    repin(i,1,n){
        if(part[i]==0){
            printf("NO\n");
            exit(0);
        }
    }
    printf("YES\n");
    repin(i,1,n){
        if(i!=1) printf(" ");
        printf("%d",part[i]);
    }
    printf("\n");
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<ctype.h>
#include<math.h>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<functional>
#include<string>
#include<algorithm>
#include<time.h>
#include<bitset>
void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T> inline void gmax(T &a,T b){if(b>a)a=b;}
template <class T> inline void gmin(T &a,T b){if(b<a)a=b;}
using namespace std;
const int N=1e5+10,M=2e5+10,Z=1e9+7,maxint=2147483647,ms31=522133279,ms63=1061109567,ms127=2139062143;const double eps=1e-8,PI=acos(-1.0);//.0
struct node
{
	int p,id;
	node(){}
	node(int p_,int id_){p=p_;id=id_;}
	bool operator < (const node &b)const
	{
		return p<b.p;
	}
};
multiset<node>sot;
multiset<node>::iterator it;
struct A
{
	int o,id;
	int l,r;
	bool operator < (const A &b)const
	{
		if(l!=b.l)return l<b.l;
		return o<b.o;
	}
}a[M];
int b[N],ans[N];
int n,m,g;
bool check()
{
	for(int i=1;i<=g;i++)
	{
		if(a[i].o==1)sot.insert(node(a[i].r,a[i].id));
		else if(a[i].o==2)
		{
			it=sot.lower_bound(node(a[i].r,-1));
			if(it==sot.end())return 0;
			int id=it->id;
			b[id]--;if(b[id]==0)sot.erase(it);
			ans[a[i].id]=id;
		}
	}
}
int main()
{
	while(~scanf("%d",&n))
	{
		g=0;
		for(int i=1;i<=n;i++)
		{
			++g;
			a[g].id=i;
			a[g].o=2;//乐器
			scanf("%d%d",&a[g].l,&a[g].r);
		}
		scanf("%d",&m);
		for(int i=1;i<=m;i++)
		{
			++g;
			a[g].id=i;
			a[g].o=1;//人
			scanf("%d%d%d",&a[g].l,&a[g].r,&b[i]);
		}
		sort(a+1,a+g+1);
		if(check())
		{
			printf("YES\n");
			for(int i=1;i<=n;i++)printf("%d ",ans[i]);
			puts("");
		}
		else printf("NO\n");
	}
	return 0;
}
/*
【题意】
http://codeforces.com/contest/496/problem/E

这题还是很水的。
比赛的时候已经想到了做法，然而想到的却是用线段树实现。导致没有写出来，我好蠢！
STL中的set和multiset真是好东西！

题意：
乐谱有n部分，第i部分有一个音调区间[li,ri]，歌唱需要且仅需要一个人。
有m个人，第i个人的音调区间是[li,ri]，他能够最多唱ki部分乐谱。

想问你，是否能有一种分配方案，使得乐谱的所有n部分都能够被歌唱。
如果有，输出YES以及每个乐谱的演唱者。
如果没有，输出NO

【类型】
区间覆盖问题
排序+multiset

【分析】
有双边界的区间覆盖问题。
我们很常用的做法是，左界排序，然后处理右界。

这道题的边界很大，不要紧。排序完就相当于完成了离散化。
（而且数据很大，开线段树稍微麻烦怎么办？想到使用set！）
我们按照左界排好序的顺序滚动。如果相同左界，人在前，乐谱在后。

如果是歌手，把它的音调上届插入multiset中，并且标记着他的id。
如果是乐谱，就一定要找匹配了。
要从歌手中中取出右界比其右界大且最小的歌手（因为他可以，而且他在未来的决策中最没用）

这个可以利用multiset的lower_bound功能实现。

题目中还有一点需要注意，就是每个人最多可以唱k个部分，怎么实现呢？
我们把每个人最多可以唱的部分属记在b[]，如果要用这个人，b[]就--，减到0的话就自动从multiset中抹掉。
然后就AC啦

【时间复杂度&&优化】
O(nlogn)

【trick】

【数据】
Input
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output
YES
1 1 2

Input
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output
NO

*/


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

#define N 100010

int n, a[N], b[N], m, c[N], d[N], f[N];
typedef pair<int, int> pii;
const int inf = 0x3f3f3f3f;
int ans[N];

int main() {
	scanf("%d", &n);
	vector<pii> v, w;
	for (int i = 1; i <= n; i ++) {
		scanf("%d%d", &a[i], &b[i]);
		v.emplace_back(a[i], i);
	}
	scanf("%d", &m);
	for (int i = 1; i <= m; i ++) {
		scanf("%d%d%d", &c[i], &d[i], &f[i]);
		w.emplace_back(c[i], i);
	}
	sort(v.begin(), v.end());
	sort(w.begin(), w.end());
	v.emplace_back(inf, 0);
	w.emplace_back(inf, 0);
	int now = 0;
	set<int> parts;
	set<pii> actors;
	for (int i = 0, j = 0; i < v.size() && j < w.size();) {
		now = min(v[i].first, w[j].first);
		if (now == inf) break;
		while (w[j].first == now) {
			actors.emplace(d[w[j].second], w[j].second);
			j ++;
		}
		while (v[i].first == now) {
			int j = v[i].second;
			if (!actors.empty()) {
				auto it = actors.lower_bound(pii(b[j],0));
				if (it != actors.end()) {
					int k = it -> second;
					ans[j] = k;
					f[k] --;
					if (!f[k]) actors.erase(it);
				}
			}
			i ++;
		}
	}
	for (int i = 1; i <= n; i ++) {
		if (!ans[i]) {
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	for (int i = 1; i <= n; i ++) printf("%d ", ans[i]);
	return 0;
}

                                                                                //hellobig_tq
//orzlxr!//hello//hello


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

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

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sf(x) sort(x.begin(),x.end(),func)
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = 1e19;
const ll ninf = LLONG_MIN;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll n, m;
pair < pl , ll > actors[N], parts[N];
ll cap[N], ans[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    f(i, n)
    {
        cin >> parts[i].F.F >> parts[i].F.S;
        parts[i].S = i;
    }
    cin >> m;
    f(i, m)
    {
        cin >> actors[i].F.F >> actors[i].F.S >> cap[i];
        actors[i].S = i;
    }
    sort(actors, actors + m);
    sort(parts, parts + n);
    ll p = 0;
    set < pl > curr;
    f(i, n)
    {
        while(p < m && actors[p].F.F <= parts[i].F.F)
        {
            curr.insert({actors[p].F.S, actors[p].S});
            p++;
        }
        auto it = curr.lower_bound(mp(parts[i].F.S, -1));
        if(it == curr.end())
        {
            cout << "NO\n";
            return 0;
        }
        auto v = *it;
        cap[v.S]--;
        if(cap[v.S] == 0) curr.erase(it);

        ans[parts[i].S] = v.S;
    }
    cout << "YES\n";
    f(i, n) cout << ans[i] + 1 << " ";
    cout << "\n";
    return 0;
}


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

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

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sf(x) sort(x.begin(),x.end(),func)
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = 1e19;
const ll ninf = LLONG_MIN;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll n, m;
pair < pl , ll > actors[N], parts[N];
ll cap[N], ans[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    f(i, n)
    {
        cin >> parts[i].F.F >> parts[i].F.S;
        parts[i].S = i;
    }
    cin >> m;
    f(i, m)
    {
        cin >> actors[i].F.F >> actors[i].F.S >> cap[i];
        actors[i].S = i;
    }
    sort(actors, actors + m);
    sort(parts, parts + n);
    ll p = 0;
    set < pl > curr;
    f(i, n)
    {
        while(p < m && actors[p].F.F <= parts[i].F.F)
        {
            curr.insert({actors[p].F.S, actors[p].S});
            p++;
        }
        auto it = curr.lower_bound(mp(parts[i].F.S, -1));
        if(it == curr.end())
        {
            cout << "NO\n";
            return 0;
        }
        cap[it -> S]--;
        if(cap[it -> S] == 0) curr.erase(it);
        ans[parts[i].S] = it -> S;
    }
    cout << "YES\n";
    f(i, n) cout << ans[i] + 1 << " ";
    cout << "\n";
    return 0;
}


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

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

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sf(x) sort(x.begin(),x.end(),func)
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define f(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = 1e19;
const ll ninf = LLONG_MIN;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll n, m;
pair < pl , ll > actors[N], parts[N];
ll cap[N], ans[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    f(i, n)
    {
        cin >> parts[i].F.F >> parts[i].F.S;
        parts[i].S = i;
    }
    cin >> m;
    f(i, m)
    {
        cin >> actors[i].F.F >> actors[i].F.S >> cap[i];
        actors[i].S = i;
    }
    sort(actors, actors + m);
    sort(parts, parts + n);
    ll p = 0;
    set < pl > curr;
    f(i, n)
    {
        while(p < m && actors[p].F.F <= parts[i].F.F)
        {
            curr.insert({actors[p].F.S, actors[p].S});
            p++;
        }
        auto it = curr.lower_bound(mp(parts[i].F.S, -1));
        if(it == curr.end())
        {
            cout << "NO\n";
            return 0;
        }
        cap[it -> S]--;
        if(cap[it -> S] == 0) curr.erase(it);
        ans[i] = it -> S;
    }
    cout << "YES\n";
    f(i, n) cout << ans[i] + 1 << " ";
    cout << "\n";
    return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <set>
const int MAXN = 1e5 + 10;

int n, m;
int a[MAXN], b[MAXN];
int c[MAXN], d[MAXN], k[MAXN];
namespace solver1 {
  void main() {
    static int seq1[MAXN], seq2[MAXN];
    for (int i = 1; i <= n; i++) {
      a[i] = 1e9 - a[i];
      seq1[i] = i;
    }
    for (int i = 1; i <= m; i++) {
      c[i] = 1e9 - c[i];
      seq2[i] = i;
    }

    std::sort(seq1 + 1, seq1 + n + 1,
              [=](int x, int y) { return a[x] < a[y]; });

    std::sort(seq2 + 1, seq2 + m + 1,
              [=](int x, int y) { return c[x] < c[y] || (c[x] == c[y] && d[x] > d[y]); });

    std::set < std::pair<int, int> > s;

    static int ans[MAXN];
    int cnt = 0;
    for (int i = 1, j = 1; i <= m; i++) {
      int x = seq2[i];
      while(j <= n && a[seq1[j]] <= c[x]) {
        s.insert({b[seq1[j]], seq1[j]});
        j++;
      }

      auto t = s.upper_bound({d[x], 1e9 + 7});
      if (t == s.begin()) continue;
      t--;
      while(1) {
        if (k[x]-- == 0) break;

        ans[t -> second] = x;
        cnt++;

        if (t == s.begin()) {
          s.erase(t--);
          break;
        } else {
          s.erase(t--);
        }
      }
    }

    if (cnt != n) {
      puts("NO");
      return;
    }

    puts("YES");
    for (int i = 1; i <= n; i++) {
      printf("%d ", ans[i]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", a + i, b + i);
  }

  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", c + i, d + i, k + i);
  }

  solver1::main();
}


#include"bits/stdc++.h"
#define LL long long
#define PII pair<int,int>
#define PPI pair<PII,int>
#define PIP pair<int,PII>
#define PPP pair<PII,PII>
#define X first
#define Y second
#define INF 1000000000
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FO_(a,b,c) for(int a=b;a>=c;a--)
#define REP(i,u,v) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])
using namespace std;
const int N = 100100;

int val[N];
int ans[N];
PPI a[N],b[N];
set<PII> que;
int main() {
	//freopen("std.in","r",stdin);
	int n;
	cin>>n;
	FOR(i,1,n) {
		a[i].Y = i;
		scanf("%d%d",&a[i].X.X,&a[i].X.Y);
	}
	sort(a+1,a+n+1);
	int m;
	cin>>m;
	FOR(i,1,m) {
		b[i].Y = i;
		scanf("%d%d%d",&b[i].X.X,&b[i].X.Y,val+i);
	}
	sort(b+1,b+m+1);
	int j = 1;
	FOR(i,1,n) {
		while(j <= n && b[j].X.X <= a[i].X.X) {
			que.insert(PII(b[j].X.Y,b[j].Y));
			j++;
		}
		auto ii = lower_bound(que.begin(),que.end(),PII(a[i].X.Y,0));
		if(ii == que.end()) {
			puts("NO");
			return 0;
		} else {
			int k = ii->Y;
			ans[a[i].Y] = k;
			if(--val[k] == 0)
				que.erase(ii);
		}
	}
	puts("YES");
	FOR(i,1,n) printf("%d ",ans[i]);
	return 0;
}


#include"bits/stdc++.h"
#define LL long long
#define PII pair<int,int>
#define PPI pair<PII,int>
#define PIP pair<int,PII>
#define PPP pair<PII,PII>
#define X first
#define Y second
#define INF 1000000000
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FO_(a,b,c) for(int a=b;a>=c;a--)
#define REP(i,u,v) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])
using namespace std;
const int N = 100100;

int val[N];
int ans[N];
PPI a[N],b[N];
set<PII> que;
int main() {
	//freopen("std.in","r",stdin);
	int n;
	cin>>n;
	FOR(i,1,n) {
		a[i].Y = i;
		scanf("%d%d",&a[i].X.X,&a[i].X.Y);
	}
	sort(a+1,a+n+1);
	int m;
	cin>>m;
	FOR(i,1,m) {
		b[i].Y = i;
		scanf("%d%d%d",&b[i].X.X,&b[i].X.Y,val+i);
	}
	sort(b+1,b+m+1);
	int j = 1;
	FOR(i,1,n) {
		while(j <= m && b[j].X.X <= a[i].X.X) {
			que.insert(PII(b[j].X.Y,b[j].Y));
			j++;
		}
		auto ii = lower_bound(que.begin(),que.end(),PII(a[i].X.Y,0));
		if(ii == que.end()) {
			puts("NO");
			return 0;
		} else {
			int k = ii->Y;
			ans[a[i].Y] = k;
			if(--val[k] == 0)
				que.erase(ii);
		}
	}
	puts("YES");
	FOR(i,1,n) printf("%d ",ans[i]);
	return 0;
}


#include"bits/stdc++.h"
#define LL long long
#define PII pair<int,int>
#define PPI pair<PII,int>
#define PIP pair<int,PII>
#define PPP pair<PII,PII>
#define X first
#define Y second
#define INF 1000000000
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FO_(a,b,c) for(int a=b;a>=c;a--)
#define REP(i,u,v) for(int i=H[u],v=to[i];i;i=nxt[i],v=to[i])
using namespace std;
const int N = 100100;

int val[N];
int ans[N];
PPI a[N],b[N];
set<PII> que;
int main() {
	//freopen("std.in","r",stdin);
	int n;
	cin>>n;
	FOR(i,1,n) {
		a[i].Y = i;
		scanf("%d%d",&a[i].X.X,&a[i].X.Y);
	}
	sort(a+1,a+n+1);
	int m;
	cin>>m;
	FOR(i,1,m) {
		b[i].Y = i;
		scanf("%d%d%d",&b[i].X.X,&b[i].X.Y,val+i);
	}
	sort(b+1,b+m+1);
	int j = 1;
	FOR(i,1,n) {
		while(j <= m && b[j].X.X <= a[i].X.X) {
			que.insert(PII(b[j].X.Y,b[j].Y));
			j++;
		}
		auto ii = que.lower_bound(PII(a[i].X.Y,0));
		if(ii == que.end()) {
			puts("NO");
			return 0;
		} else {
			int k = ii->Y;
			ans[a[i].Y] = k;
			if(--val[k] == 0)
				que.erase(ii);
		}
	}
	puts("YES");
	FOR(i,1,n) printf("%d ",ans[i]);
	return 0;
}


/*
***************************************************************************************************************

                            Author : Yash Sadhwani

**************************************************************************************************************
*/
#include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
#include<algorithm>
#include<deque>
#include<map>
#include<set>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<functional>
using namespace std;
#define ll long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sd(x) scanf("%lf",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define vl vector<ll>
#define vi vector<int>
#define vvl vector< vl >
#define vvi vector< vi >
#define pb push_back
#define mod 1000000007
#define mem(x,y) memset(x,y,sizeof(x))
#define f(i,a,b) for(int i=(a);i<(b);i++)
#define max_int_value 2147483647
#define max_long_value 9223372036854775807
#define ub(X,v) upper_bound(X.begin(),X.end(),v)
#define lb(X,v) lower_bound(X.begin(),X.end(),v)

//qsort(ww,cc,sizeof(tp),compare);
/*int compare(const void *a,const void *b){
    ll y=((((tp*)a)->w)-(((tp*)b)->w));
    if(y>0)return 1;
    else if(y==0)return 0;
    else return -1;
}
bool way(ii x,ii y){
    return x.first<y.first or x.first==y.first and x.second<y.second;
}

ll modpow(ll base, ll exponent,ll modulus){
    if(base==0&&exponent==0)return 0;
    ll result = 1;
    while (exponent > 0){
        if (exponent % 2 == 1)
            result = (result * base) % modulus;
        exponent = exponent >> 1;
        base = (base * base) % modulus;
    }
    return result;
}

#define getchar_unlocked getchar
using namespace std;
inline int scan(){
    char c = getchar_unlocked();
    int x = 0;
    while(c<'0'||c>'9'){
        c=getchar_unlocked();
    }
    while(c>='0'&&c<='9'){
        x=(x<<1)+(x<<3)+c-'0';
        c=getchar_unlocked();
    }
    return x;
}

*/

#define MAXN 100010
#define SQRT 330
#define ls (node<<1)
#define rs ((node<<1)+1)
#define ii pair<int,int>
#define F first
#define S second

ii arr[MAXN], brr[MAXN];

//contains the pair(starting point, index)
set<ii> S;

//pair(ending point, index)
vector<ii> A, B;

int N, M;

int cap[MAXN];

int ans[MAXN];

set<ii>::iterator it;

inline void go(void){
    int cnt = 0;
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int val = 0, j = 0;
    for(int i = 0; i < B.size(); i++){
        int a, b, idx;
        idx = B[i].S;
        a = arr[idx].F;
        b = arr[idx].S;
        //cout << a << " " << b << " " << idx << endl;
        while(j < A.size()){
            if(A[j].F <= b){
                S.insert(ii(brr[A[j].S].F, A[j].S));
                j++;
            }else{
                break;
            }

        }
        while(1){
            it = S.lower_bound(ii(a,0));
            if(it == S.end() or cap[idx] == 0) break;
            else{
                cap[idx]--;
                //cout <<"HEY " << it -> S << " " << idx << endl;
                ans[it -> S] = idx;
                S.erase(it);
                cnt++;
            }
        }
    }
    if(cnt == N){
        cout << "YES\n";
        for(int i = 1; i <= N; i++){
            cout << ans[i] << " ";
        }
    }else{
        cout << "NO\n";
    }
}

inline void ReadInput(void){
    si(N);
    for(int i = 1; i <= N; i++){
        int a, b;
        si(a); si(b);
        brr[i] = ii(a, b);
        A.pb(ii(b, i));
    }
    si(M);
    for(int i = 1; i <= M; i++){
        int a, b, c;
        si(a); si(b); si(c);
        arr[i] = ii(a, b);
        B.pb(ii(b, i));
        cap[i] = c;
    }
}

inline void solve(void){
    go();
}

inline void Refresh(void){

}

int main()
{
    ios_base::sync_with_stdio(false);
    ReadInput();
    solve();
    return 0;
}

// U COME AT THE KING, BETTER NOT MISS !!!


#include <bits/stdc++.h>
#define pb push_back
#define pii pair <int, int>
#define mp make_pair
#define F first
#define S second
#define ll long long
#define iosbase ios_base::sync_with_stdio(false)
#define sc scanf
#define pr printf
#define null NULL
#define getcx getchar_unlocked
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pll pair<ll,ll>
#define vi vector <int>
#define vll vector <ll>

#define maxs 200005
#define logmaxs 35

#define MOD 1000000007
#define eps 1e-9
#define llmax 1e15+5
#define intmax 1e9+5
#define intmin -intmax

#define pi 3.14159265358979

using namespace std;

vector <int> v;
vector <pii> range;
vector <pair <pii ,int> > actors;

vector <pii> R[4*maxs], A[4*maxs];
int size[maxs];
set <pii> M;
set <pii>::iterator it;
int ans[maxs];

int main(){
	int n,l,r,x;
	sc("%d", &n);
	for(int i=1; i<=n; i++){
		sc("%d %d", &l, &r);
		range.pb(mp(l,r));
		v.pb(l);
		v.pb(r);
	}
	int m;
	sc("%d", &m);
	for(int i=1; i<=m; i++){
		sc("%d %d %d", &l, &r, &x);
		actors.pb(mp(mp(l,r),x));
		v.pb(l);
		v.pb(r);
		size[i]=x;
	}
	sort(v.begin(), v.end());
	for(int i=0; i<range.size(); i++){
		range[i].F=lower_bound(v.begin(), v.end(), range[i].F)-v.begin()+1;
		range[i].S=lower_bound(v.begin(), v.end(), range[i].S)-v.begin()+1;
		R[range[i].F].pb(mp(range[i].S, i+1));
	}
	for(int i=0; i<actors.size(); i++){
		actors[i].F.F=lower_bound(v.begin(), v.end(), actors[i].F.F)-v.begin()+1;
		actors[i].F.S=lower_bound(v.begin(), v.end(), actors[i].F.S)-v.begin()+1;
		A[actors[i].F.F].pb(mp(actors[i].F.S, i+1));
	}
	// for(int i=0; i<range.size(); i++){
	// 	cout<<range[i].F<<" "<<range[i].S<<endl;
	// }
	// for(int i=0; i<actors.size(); i++){
	// 	cout<<actors[i].F.F<<" "<<actors[i].F.S<<" "<<actors[i].S<<endl;
	// }
	for(int i=1; i<4*maxs; i++){
		sort(R[i].begin(), R[i].end());
	}
	int fl=1;
	for(int i=1; i<4*maxs; i++){
		for(int j=0; j<A[i].size(); j++){
			M.insert(mp(A[i][j].F, A[i][j].S));
		}
		while(true){
			if(M.empty()){
					break;
			}
			if((*M.begin()).first<i)M.erase(M.begin());
			else break;
		}
		for(int j=0; j<R[i].size(); j++){
			if(M.empty()){
				fl=0;
				break;
			}
			int id;
			it=M.lower_bound(mp(R[i][j].F, 0));
			if(it==M.end()){
				fl=0;
				break;
			}
			else
			id=(*it).second;
			//cout<<id<<" "<<M.size()<<endl;
			ans[R[i][j].S]=id;
			size[id]--;
			if(size[id]==0){
				M.erase(it);
			}
		}

		if(!fl)break;
	}
	if(!fl){
		pr("NO\n");
		return 0;
	}
	pr("YES\n");
	for(int i=1; i<=n; i++){
		pr("%d ", ans[i]);
	}
	pr("\n");
	return 0;

}


#include <bits/stdc++.h>
#define pb push_back
#define pii pair <int, int>
#define mp make_pair
#define F first
#define S second
#define ll long long
#define iosbase ios_base::sync_with_stdio(false)
#define sc scanf
#define pr printf
#define null NULL
#define getcx getchar_unlocked
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pll pair<ll,ll>
#define vi vector <int>
#define vll vector <ll>

#define maxs 200005
#define logmaxs 35

#define MOD 1000000007
#define eps 1e-9
#define llmax 1e15+5
#define intmax 1e9+5
#define intmin -intmax

#define pi 3.14159265358979

using namespace std;

vector <int> v;
vector <pii> range;
vector <pair <pii ,int> > actors;

vector <pii> R[4*maxs], A[4*maxs];
int size[maxs];
set <pii> M;
int ans[maxs];

int main(){
	int n,l,r,x;
	sc("%d", &n);
	for(int i=1; i<=n; i++){
		sc("%d %d", &l, &r);
		range.pb(mp(l,r));
		v.pb(l);
		v.pb(r);
	}
	int m;
	sc("%d", &m);
	for(int i=1; i<=m; i++){
		sc("%d %d %d", &l, &r, &x);
		actors.pb(mp(mp(l,r),x));
		v.pb(l);
		v.pb(r);
		size[i]=x;
	}
	sort(v.begin(), v.end());
	for(int i=0; i<range.size(); i++){
		range[i].F=lower_bound(v.begin(), v.end(), range[i].F)-v.begin()+1;
		range[i].S=lower_bound(v.begin(), v.end(), range[i].S)-v.begin()+1;
		R[range[i].F].pb(mp(range[i].S, i+1));
	}
	for(int i=0; i<actors.size(); i++){
		actors[i].F.F=lower_bound(v.begin(), v.end(), actors[i].F.F)-v.begin()+1;
		actors[i].F.S=lower_bound(v.begin(), v.end(), actors[i].F.S)-v.begin()+1;
		A[actors[i].F.F].pb(mp(actors[i].F.S, i+1));
	}
	for(int i=1; i<4*maxs; i++){
		sort(R[i].begin(), R[i].end());
	}
	int fl=1;
	for(int i=1; i<4*maxs; i++){
		for(int j=0; j<A[i].size(); j++){
			M.insert(mp(A[i][j].F, A[i][j].S));
		}
		for(int j=0; j<R[i].size(); j++){
			if(M.empty()){
				fl=0;
				break;
			}
			while(true){
				if(M.empty()){
					fl=0;break;
				}
				if((*M.begin()).first<R[i][j].F)M.erase(M.begin());
				else break;
			}
			int id=(*M.begin()).second;
			ans[R[i][j].S]=id;
			size[id]--;
			if(size[id]==0){
				M.erase(M.begin());
			}
		}

		if(!fl)break;
	}
	if(!fl){
		pr("NO\n");
		return 0;
	}
	pr("YES\n");
	for(int i=1; i<=n; i++){
		pr("%d ", ans[i]);
	}
	pr("\n");
	return 0;

}


#include <bits/stdc++.h>
#define pb push_back
#define pii pair <int, int>
#define mp make_pair
#define F first
#define S second
#define ll long long
#define iosbase ios_base::sync_with_stdio(false)
#define sc scanf
#define pr printf
#define null NULL
#define getcx getchar_unlocked
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define pll pair<ll,ll>
#define vi vector <int>
#define vll vector <ll>

#define maxs 200005
#define logmaxs 35

#define MOD 1000000007
#define eps 1e-9
#define llmax 1e15+5
#define intmax 1e9+5
#define intmin -intmax

#define pi 3.14159265358979

using namespace std;

vector <int> v;
vector <pii> range;
vector <pair <pii ,int> > actors;

vector <pii> R[4*maxs], A[4*maxs];
int size[maxs];
set <pii> M;
int ans[maxs];

int main(){
	int n,l,r,x;
	sc("%d", &n);
	for(int i=1; i<=n; i++){
		sc("%d %d", &l, &r);
		range.pb(mp(l,r));
		v.pb(l);
		v.pb(r);
	}
	int m;
	sc("%d", &m);
	for(int i=1; i<=m; i++){
		sc("%d %d %d", &l, &r, &x);
		actors.pb(mp(mp(l,r),x));
		v.pb(l);
		v.pb(r);
		size[i]=x;
	}
	sort(v.begin(), v.end());
	for(int i=0; i<range.size(); i++){
		range[i].F=lower_bound(v.begin(), v.end(), range[i].F)-v.begin()+1;
		range[i].S=lower_bound(v.begin(), v.end(), range[i].S)-v.begin()+1;
		R[range[i].F].pb(mp(range[i].S, i+1));
	}
	for(int i=0; i<actors.size(); i++){
		actors[i].F.F=lower_bound(v.begin(), v.end(), actors[i].F.F)-v.begin()+1;
		actors[i].F.S=lower_bound(v.begin(), v.end(), actors[i].F.S)-v.begin()+1;
		A[actors[i].F.F].pb(mp(actors[i].F.S, i+1));
	}
	for(int i=1; i<4*maxs; i++){
		sort(R[i].begin(), R[i].end());
	}
	int fl=1;
	for(int i=1; i<4*maxs; i++){
		for(int j=0; j<A[i].size(); j++){
			M.insert(mp(A[i][j].F, A[i][j].S));
		}
		for(int j=0; j<R[i].size(); j++){
			if(M.empty()){
				fl=0;
				break;
			}
			while(true){
				if(M.empty())break;
				if((*M.begin()).first<R[i][j].F)M.erase(M.begin());
				else break;
			}
			int id=(*M.begin()).second;
			ans[R[i][j].S]=id;
			size[id]--;
			if(size[id]==0){
				M.erase(M.begin());
			}
		}

		if(!fl)break;
	}
	if(!fl){
		pr("NO\n");
		return 0;
	}
	pr("YES\n");
	for(int i=1; i<=n; i++){
		pr("%d ", ans[i]);
	}
	pr("\n");
	return 0;

}