There are $$$n$$$ cities and $$$m$$$ bidirectional roads in the country. The roads in the country form an undirected weighted graph. The graph is not guaranteed to be connected. Each road has it's own parameter $$$w$$$. You can travel through the roads, but the government made a new law: you can only go through two roads at a time (go from city $$$a$$$ to city $$$b$$$ and then from city $$$b$$$ to city $$$c$$$) and you will have to pay $$$(w_{ab} + w_{bc})^2$$$ money to go through those roads. Find out whether it is possible to travel from city $$$1$$$ to every other city $$$t$$$ and what's the minimum amount of money you need to get from $$$1$$$ to $$$t$$$.

First line contains two integers $$$n$$$, $$$m$$$ ($$$2 \leq n \leq 10^5$$$, $$$1 \leq m \leq min(\frac{n \cdot (n - 1)}{2}, 2 \cdot 10^5)$$$). Next $$$m$$$ lines each contain three integers $$$v_i$$$, $$$u_i$$$, $$$w_i$$$ ($$$1 \leq v_i, u_i \leq n$$$, $$$1 \leq w_i \leq 50$$$, $$$u_i \neq v_i$$$). It's guaranteed that there are no multiple edges, i.e. for any edge $$$(u_i, v_i)$$$ there are no other edges $$$(u_i, v_i)$$$ or $$$(v_i, u_i)$$$.

For every city $$$t$$$ print one integer. If there is no correct path between $$$1$$$ and $$$t$$$ output $$$-1$$$. Otherwise print out the minimum amount of money needed to travel from $$$1$$$ to $$$t$$$.

NoteThe graph in the first example looks like this.In the second example the path from $$$1$$$ to $$$3$$$ goes through $$$2$$$, so the resulting payment is $$$(1 + 2)^2 = 9$$$.

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int64]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}
	pq := &PriorityQueue{}

	dist[0] = 0
	start := pqitem{}
	heap.Push(pq, start)

	for pq.Len() > 0 {
		currState := heap.Pop(pq).(pqitem)

		hashstate := [2]int64{currState.node, currState.prevWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if currState.isMiddle {
			for _, e := range adj[currState.node] {
				edgeWeight := (currState.prevWeight + e.weight)
				d := currState.fromDist + edgeWeight*edgeWeight
				if dist[e.next] > d {
					dist[e.next] = d
					heap.Push(pq, pqitem{
						node:       e.next,
						isMiddle:   false,
						fromDist:   d,
						prevWeight: 0,
					})
				}
			}
		} else {
			for _, e := range adj[currState.node] {
				heap.Push(pq, pqitem{
					node:       e.next,
					isMiddle:   true,
					fromDist:   dist[currState.node],
					prevWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int64
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int64
}

type PriorityQueue []pqitem

type pqitem struct {
	node       int64
	isMiddle   bool
	fromDist   int64
	prevWeight int64
}

func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].isMiddle {
		return true
	}
	if pq[j].isMiddle {
		return false
	}
	return pq[i].fromDist < pq[j].fromDist
}

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Swap(i, j int) { pq[i], pq[j] = pq[j], pq[i] }

func (pq *PriorityQueue) Push(x interface{}) { *pq = append(*pq, x.(pqitem)) }

func (pq *PriorityQueue) Pop() interface{} {
	ret := (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return ret
}

package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[int64]bool)
	visitedMiddle := make(map[[2]int64]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}
	pq := &PriorityQueue{}

	start := pqitem{isMiddle: false}
	dist[0] = 0
	heap.Push(pq, start)

	for pq.Len() > 0 {
		currState := heap.Pop(pq).(pqitem)
		if currState.isMiddle {
			hashstate := [2]int64{currState.node, currState.prevWeight}
			if visitedMiddle[hashstate] {
				continue
			}
			visitedMiddle[hashstate] = true
			for _, e := range adj[currState.node] {
				edgeWeight := (currState.prevWeight + e.weight) * (currState.prevWeight + e.weight)
				if dist[e.next] > currState.fromDist+edgeWeight {
					dist[e.next] = currState.fromDist + edgeWeight
					heap.Push(pq, pqitem{
						node:       e.next,
						isMiddle:   false,
						fromDist:   dist[e.next],
						prevWeight: -1,
					})
				}
			}
		} else {
			if visited[currState.node] {
				continue
			}
			visited[currState.node] = true
			for _, e := range adj[currState.node] {
				heap.Push(pq, pqitem{
					node:       e.next,
					isMiddle:   true,
					fromDist:   dist[currState.node],
					prevWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int64
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int64
}

type PriorityQueue []pqitem

type pqitem struct {
	node       int64
	isMiddle   bool
	fromDist   int64
	prevWeight int64
}

func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].isMiddle {
		return true
	}
	if pq[j].isMiddle {
		return false
	}
	return pq[i].fromDist < pq[j].fromDist
}

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Swap(i, j int) { pq[i], pq[j] = pq[j], pq[i] }

func (pq *PriorityQueue) Push(x interface{}) { *pq = append(*pq, x.(pqitem)) }

func (pq *PriorityQueue) Pop() interface{} {
	ret := (*pq)[len(*pq)-1]
	*pq = (*pq)[:len(*pq)-1]
	return ret
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}

	pq := &minheap{}
	pq.push(state{})
	dist[0] = 0

	for pq.len() > 0 {
		s := pq.pop()

		hashstate := [2]int{s.node, s.prevEdgeWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if s.middle == 1 {
			for _, e := range adj[s.node] {
				cost := int64(s.prevEdgeWeight + e.weight)
				d := s.dist + cost*cost
				if dist[e.next] > d {
					dist[e.next] = d
					pq.push(state{
						node:           e.next,
						middle:         s.middle ^ 1,
						dist:           d,
						prevEdgeWeight: 0,
					})
				}
			}
		} else {
			for _, e := range adj[s.node] {
				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[s.node],
					prevEdgeWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int
}

type state struct {
	middle         byte
	node           int
	dist           int64
	prevEdgeWeight int
}

func lessop(s0, s1 state) bool {
	if s0.middle == 1 {
		return true
	}
	if s1.middle == 1 {
		return false
	}
	return s0.dist < s1.dist
}

type minheap []state

func (h *minheap) push(x state) {
	*h = append(*h, x)
	h.up(len(*h) - 1)
}

func (h *minheap) pop() state {
	old := *h
	n := len(old)
	top := old[0]

	old[0], old[n-1] = old[n-1], old[0]
	*h = old[:n-1]
	h.down(0)

	return top
}

func (h minheap) up(j int) {
	for j > 0 {
		i := (j - 1) / 2
		if !lessop(h[j], h[i]) {
			break
		}
		h[i], h[j] = h[j], h[i]
		j = i
	}
}

func (h minheap) down(j int) {
	i := j
	for {
		mini, l, r := i, 2*i+1, 2*i+2
		if l < len(h) && lessop(h[l], h[mini]) {
			mini = l
		}
		if r < len(h) && lessop(h[r], h[mini]) {
			mini = r
		}
		if mini == i {
			break
		}
		h[i], h[mini] = h[mini], h[i]
		i = mini
	}
}

func (h *minheap) len() int {
	return len(*h)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}

	pq := &minheap{}
	pq.push(state{})
	dist[0] = 0

	for pq.len() > 0 {
		s := pq.pop()

		hashstate := [2]int{s.node, s.prevEdgeWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if s.middle == 1 {
			for _, e := range adj[s.node] {
				cost := int64(s.prevEdgeWeight + e.weight)
				d := s.dist + cost*cost
				if dist[e.next] > d {
					dist[e.next] = d
					pq.push(state{
						node:           e.next,
						middle:         s.middle ^ 1,
						dist:           dist[e.next],
						prevEdgeWeight: 0,
					})
				}
			}
		} else {
			for _, e := range adj[s.node] {
				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[s.node],
					prevEdgeWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int
}

type state struct {
	middle         byte
	node           int
	dist           int64
	prevEdgeWeight int
}

func lessop(s0, s1 state) bool {
	if s0.middle == 1 {
		return true
	}
	if s1.middle == 1 {
		return false
	}
	return s0.dist < s1.dist
}

type minheap []state

func (h *minheap) push(x state) {
	*h = append(*h, x)
	h.up(len(*h) - 1)
}

func (h *minheap) pop() state {
	old := *h
	n := len(old)
	top := old[0]

	old[0], old[n-1] = old[n-1], old[0]
	*h = (*h)[:n-1]
	h.down(0)

	return top
}

func (h minheap) up(j int) {
	for j > 0 {
		i := (j - 1) / 2
		if !lessop(h[j], h[i]) {
			break
		}
		h[i], h[j] = h[j], h[i]
		j = i
	}
}

func (h minheap) down(j int) {
	i := j
	for {
		mini, l, r := i, 2*i+1, 2*i+2
		if l < len(h) && lessop(h[l], h[mini]) {
			mini = l
		}
		if r < len(h) && lessop(h[r], h[mini]) {
			mini = r
		}
		if mini == i {
			break
		}
		h[i], h[mini] = h[mini], h[i]
		i = mini
	}
}

func (h *minheap) len() int {
	return len(*h)
}

package main

import (
	"bufio"
	"bytes"
	"container/heap"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, m := readTwoNums(reader)

	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 3)
	}

	res := solve(n, m, E)

	var buf bytes.Buffer

	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 1 << 60

func solve(n int, m int, E [][]int) []int64 {
	g := NewGraph(n, m*2)

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		g.AddEdge(u-1, v-1, int64(w))
		g.AddEdge(v-1, u-1, int64(w))
	}

	mn := make([]int64, n)
	dist := make([]int64, n)

	for i := 0; i < n; i++ {
		mn[i] = INF
		dist[i] = INF
	}

	//mn[0] = 0
	dist[0] = 0

	pq := make(PriorityQueue, 0, n)
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)
		u := cur.value
		if dist[u] < cur.priority {
			continue
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if mn[v] > g.val[i] {
				for j := g.nodes[v]; j > 0; j = g.next[j] {
					x := g.to[j]
					w := g.val[i] + g.val[j]
					if dist[x] > dist[u]+w*w {
						dist[x] = dist[u] + w*w
						heap.Push(&pq, NewItem(x, dist[x]))
					}
				}
				mn[v] = g.val[i]
			}
		}
	}

	for i := 0; i < n; i++ {
		if dist[i] == INF {
			dist[i] = -1
		}
	}
	return dist
}

func solve1(n int, m int, E [][]int) []int64 {
	g := NewGraph(n*51, 2*m*51)

	connect := func(u, v, w int) {
		g.AddEdge(u*51, v*51+w, 0)
		for was := 1; was <= 50; was++ {
			g.AddEdge(u*51+was, v*51, int64(was+w)*int64(was+w))
		}
	}

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		connect(u-1, v-1, w)
		connect(v-1, u-1, w)
	}

	dist := make([]int64, n*51)
	for i := 0; i < len(dist); i++ {
		dist[i] = INF
	}
	pq := make(PriorityQueue, 0, n)
	dist[0] = 0
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)

		u := cur.value

		if dist[u] < cur.priority {
			continue
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if dist[v] > cur.priority+g.val[i] {
				dist[v] = cur.priority + g.val[i]
				heap.Push(&pq, NewItem(v, dist[v]))
			}
		}
	}

	res := make([]int64, n)

	for i := 0; i < n; i++ {
		if dist[51*i] == INF {
			res[i] = -1
		} else {
			res[i] = dist[i*51]
		}
	}

	return res
}

type Graph struct {
	count []int
	nodes []int
	next  []int
	to    []int
	val   []int64
	cur   int
}

func NewGraph(n int, e int) *Graph {
	count := make([]int, n)
	nodes := make([]int, n)
	next := make([]int, e+10)
	to := make([]int, e+10)
	val := make([]int64, e+10)
	return &Graph{count, nodes, next, to, val, 0}
}

func (g *Graph) AddEdge(u, v int, w int64) {
	g.count[u]++
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
	g.val[g.cur] = w
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    int   // The value of the item; arbitrary.
	priority int64 // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

func NewItem(v int, p int64) *Item {
	item := new(Item)
	item.value = v
	item.priority = p
	return item
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, priority int64) {
	item.priority = priority
	heap.Fix(pq, item.index)
}

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
type pair struct{ v, d int }
type hp []pair

func (h hp) Len() int              { return len(h) }
func (h hp) Less(i, j int) bool    { return h[i].d < h[j].d }
func (h hp) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{})   { *h = append(*h, v.(pair)) }
func (h *hp) Pop() (v interface{}) { a := *h; *h, v = a[:len(a)-1], a[len(a)-1]; return }
func (h *hp) push(v pair)          { heap.Push(h, v) }
func (h *hp) pop() pair            { return heap.Pop(h).(pair) }

func CF1486E(_r io.Reader, _w io.Writer) {
	out := bufio.NewWriter(_w)
	defer out.Flush()
	_i, _n, buf := 0, 0, make([]byte, 1<<12)
	rc := func() byte {
		if _i == _n {
			_n, _ = _r.Read(buf)
			if _n == 0 {
				return 0
			}
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	const inf int = 1e9
	type nb struct{ to, wt int }

	n, m := r(), r()
	g := make([][]nb, n)
	for i := 0; i < m; i++ {
		v, w, wt := r()-1, r()-1, r()
		g[v] = append(g[v], nb{w, wt})
		g[w] = append(g[w], nb{v, wt})
	}
	dist := make([]int, n)
	mi := make([]int, n)
	for i := range dist {
		dist[i] = inf
		mi[i] = inf
	}
	dist[0] = 0
	q := hp{{}}
	for len(q) > 0 {
		p := q.pop()
		v := p.v
		if p.d > dist[v] {
			continue
		}
		for _, e := range g[v] {
			w, wt := e.to, e.wt
			if wt >= mi[w] {
				continue
			}
			mi[w] = wt
			for _, e2 := range g[w] {
				u := e2.to
				if newD := dist[v] + (wt+e2.wt)*(wt+e2.wt); newD < dist[u] {
					dist[u] = newD
					q.push(pair{u, newD})
				}
			}
		}
	}
	for _, v := range dist {
		if v == inf {
			v = -1
		}
		Fprint(out, v, " ")
	}
}

func main() { CF1486E(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"container/heap"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
type pair struct{ v, d int }
type hp []pair

func (h hp) Len() int              { return len(h) }
func (h hp) Less(i, j int) bool    { return h[i].d < h[j].d }
func (h hp) Swap(i, j int)         { h[i], h[j] = h[j], h[i] }
func (h *hp) Push(v interface{})   { *h = append(*h, v.(pair)) }
func (h *hp) Pop() (v interface{}) { a := *h; *h, v = a[:len(a)-1], a[len(a)-1]; return }
func (h *hp) push(v pair)          { heap.Push(h, v) }
func (h *hp) pop() pair            { return heap.Pop(h).(pair) }

func CF1486E(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const inf int = 1e9
	type nb struct{ to, wt int }

	var n, m, v, w, wt int
	Fscan(in, &n, &m)
	g := make([][]nb, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w, &wt)
		v--
		w--
		g[v] = append(g[v], nb{w, wt})
		g[w] = append(g[w], nb{v, wt})
	}
	dist := make([]int, n)
	mi := make([]int, n)
	for i := range dist {
		dist[i] = inf
		mi[i] = inf
	}
	dist[0] = 0
	q := hp{{}}
	for len(q) > 0 {
		p := q.pop()
		v := p.v
		if p.d > dist[v] {
			continue
		}
		for _, e := range g[v] {
			w, wt := e.to, e.wt
			if wt >= mi[w] {
				continue
			}
			mi[w] = wt
			for _, e2 := range g[w] {
				u := e2.to
				if newD := dist[v] + (wt+e2.wt)*(wt+e2.wt); newD < dist[u] {
					dist[u] = newD
					q.push(pair{u, newD})
				}
			}
		}
	}
	for _, v := range dist {
		if v == inf {
			v = -1
		}
		Fprint(out, v, " ")
	}
}

func main() { CF1486E(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"os"
)

const inf int64 = 1 << 60

func solve(adj [][]edge) {
	visited := make(map[[2]int]bool)
	dist := make([]int64, len(adj))
	for i := range dist {
		dist[i] = inf
	}

	pq := &minheap{}
	pq.push(state{})
	dist[0] = 0

	for pq.len() > 0 {
		s := pq.pop()

		hashstate := [2]int{s.node, s.prevEdgeWeight}
		if visited[hashstate] {
			continue
		}
		visited[hashstate] = true

		if s.middle == 1 {
			for _, e := range adj[s.node] {
				w := int64(s.prevEdgeWeight + e.weight)
				d := s.dist + w*w
				if dist[e.next] > d {
					dist[e.next] = d
				}

				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[e.next],
					prevEdgeWeight: 0,
				})
			}
		} else {
			for _, e := range adj[s.node] {
				pq.push(state{
					node:           e.next,
					middle:         s.middle ^ 1,
					dist:           dist[s.node],
					prevEdgeWeight: e.weight,
				})
			}
		}
	}

	for i := range dist {
		if dist[i] != inf {
			printf("%d ", dist[i])
		} else {
			printf("-1 ")
		}
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	//scan(&T)
	for t := 0; t < T; t++ {
		var n, m int64
		scan(&n, &m)

		adj := make([][]edge, n)
		for i := 0; i < int(m); i++ {
			var u, v, w int
			scan(&u, &v, &w)
			adj[u-1] = append(adj[u-1], edge{v - 1, w})
			adj[v-1] = append(adj[v-1], edge{u - 1, w})
		}

		solve(adj)
	}
}

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

// ---

type edge struct {
	next, weight int
}

type state struct {
	middle         byte
	node           int
	dist           int64
	prevEdgeWeight int
}

func lessop(s0, s1 state) bool {
	if s0.middle == 1 {
		return true
	}
	if s1.middle == 1 {
		return false
	}
	return s0.dist < s1.dist
}

type minheap []state

func (h *minheap) push(x state) {
	*h = append(*h, x)
	h.up(len(*h) - 1)
}

func (h *minheap) pop() state {
	old := *h
	n := len(old)
	top := old[0]

	old[0], old[n-1] = old[n-1], old[0]
	*h = old[:n-1]
	h.down(0)

	return top
}

func (h minheap) up(j int) {
	for j > 0 {
		i := (j - 1) / 2
		if !lessop(h[j], h[i]) {
			break
		}
		h[i], h[j] = h[j], h[i]
		j = i
	}
}

func (h minheap) down(j int) {
	i := j
	for {
		mini, l, r := i, 2*i+1, 2*i+2
		if l < len(h) && lessop(h[l], h[i]) {
			mini = l
		}
		if r < len(h) && lessop(h[r], h[i]) {
			mini = r
		}
		if mini == i {
			break
		}
		h[i], h[mini] = h[mini], h[i]
		i = mini
	}
}

func (h *minheap) len() int {
	return len(*h)
}

package main

import (
	"bufio"
	"bytes"
	"container/heap"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	n, m := readTwoNums(reader)

	E := make([][]int, m)
	for i := 0; i < m; i++ {
		E[i] = readNNums(reader, 3)
	}

	res := solve(n, m, E)

	var buf bytes.Buffer

	for i := 0; i < n; i++ {
		buf.WriteString(fmt.Sprintf("%d ", res[i]))
	}

	fmt.Print(buf.String())
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

const INF = 1 << 60

func solve(n int, m int, E [][]int) []int64 {
	g := NewGraph(n, m*2)

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		g.AddEdge(u-1, v-1, int64(w))
		g.AddEdge(v-1, u-1, int64(w))
	}

	mn := make([]int64, n)
	dist := make([]int64, n)

	for i := 0; i < n; i++ {
		mn[i] = INF
		dist[i] = INF
	}

	//mn[0] = 0
	dist[0] = 0

	pq := make(PriorityQueue, 0, n)
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)
		u := cur.value
		if dist[u] < cur.priority {
			continue
		}
		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if mn[v] > cur.priority {
				for j := g.nodes[v]; j > 0; j = g.next[j] {
					x := g.to[j]
					w := g.val[i] + g.val[j]
					if dist[x] > dist[u]+w*w {
						dist[x] = dist[u] + w*w
						heap.Push(&pq, NewItem(x, dist[x]))
					}
				}
				mn[v] = cur.priority
			}
		}
	}

	for i := 0; i < n; i++ {
		if dist[i] == INF {
			dist[i] = -1
		}
	}
	return dist
}

func solve1(n int, m int, E [][]int) []int64 {
	g := NewGraph(n*51, 2*m*51)

	connect := func(u, v, w int) {
		g.AddEdge(u*51, v*51+w, 0)
		for was := 1; was <= 50; was++ {
			g.AddEdge(u*51+was, v*51, int64(was+w)*int64(was+w))
		}
	}

	for _, e := range E {
		u, v, w := e[0], e[1], e[2]
		connect(u-1, v-1, w)
		connect(v-1, u-1, w)
	}

	dist := make([]int64, n*51)
	for i := 0; i < len(dist); i++ {
		dist[i] = INF
	}
	pq := make(PriorityQueue, 0, n)
	dist[0] = 0
	heap.Push(&pq, NewItem(0, 0))

	for pq.Len() > 0 {
		cur := heap.Pop(&pq).(*Item)

		u := cur.value

		if dist[u] < cur.priority {
			continue
		}

		for i := g.nodes[u]; i > 0; i = g.next[i] {
			v := g.to[i]
			if dist[v] > cur.priority+g.val[i] {
				dist[v] = cur.priority + g.val[i]
				heap.Push(&pq, NewItem(v, dist[v]))
			}
		}
	}

	res := make([]int64, n)

	for i := 0; i < n; i++ {
		if dist[51*i] == INF {
			res[i] = -1
		} else {
			res[i] = dist[i*51]
		}
	}

	return res
}

type Graph struct {
	count []int
	nodes []int
	next  []int
	to    []int
	val   []int64
	cur   int
}

func NewGraph(n int, e int) *Graph {
	count := make([]int, n)
	nodes := make([]int, n)
	next := make([]int, e+10)
	to := make([]int, e+10)
	val := make([]int64, e+10)
	return &Graph{count, nodes, next, to, val, 0}
}

func (g *Graph) AddEdge(u, v int, w int64) {
	g.count[u]++
	g.cur++
	g.next[g.cur] = g.nodes[u]
	g.nodes[u] = g.cur
	g.to[g.cur] = v
	g.val[g.cur] = w
}

// An Item is something we manage in a priority queue.
type Item struct {
	value    int   // The value of the item; arbitrary.
	priority int64 // The priority of the item in the queue.
	// The index is needed by update and is maintained by the heap.Interface methods.
	index int // The index of the item in the heap.
}

func NewItem(v int, p int64) *Item {
	item := new(Item)
	item.value = v
	item.priority = p
	return item
}

// A PriorityQueue implements heap.Interface and holds Items.
type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	// We want Pop to give us the highest, not lowest, priority so we use greater than here.
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

// update modifies the priority and value of an Item in the queue.
func (pq *PriorityQueue) update(item *Item, priority int64) {
	item.priority = priority
	heap.Fix(pq, item.index)
}


Vika has n jars with paints of distinct colors. All the jars are numbered from 1 to n and the i-th jar contains ai liters of paint of color i.Vika also has an infinitely long rectangular piece of paper of width 1, consisting of squares of size 1 × 1. Squares are numbered 1, 2, 3 and so on. Vika decided that she will start painting squares one by one from left to right, starting from the square number 1 and some arbitrary color. If the square was painted in color x, then the next square will be painted in color x + 1. In case of x = n, next square is painted in color 1. If there is no more paint of the color Vika wants to use now, then she stops.Square is always painted in only one color, and it takes exactly 1 liter of paint. Your task is to calculate the maximum number of squares that might be painted, if Vika chooses right color to paint the first square.

The first line of the input contains a single integer n (1 ≤ n ≤ 200 000) — the number of jars with colors Vika has. The second line of the input contains a sequence of integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is equal to the number of liters of paint in the i-th jar, i.e. the number of liters of color i that Vika has.

The only line of the output should contain a single integer — the maximum number of squares that Vika can paint if she follows the rules described above.

NoteIn the first sample the best strategy is to start painting using color 4. Then the squares will be painted in the following colors (from left to right): 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5.In the second sample Vika can start to paint using any color.In the third sample Vika should start painting using color number 5.

package main

import (
    "bufio"
    "fmt"
    "os"
)

func min(a, b int64) int64 {
  if a < b {
    return a
  }
  return b
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int

    fmt.Fscan(stdin, &n)
    a := make([]int64, n)
    m := int64(1000000001)
    for i := 0; i < n; i++ {
      fmt.Fscan(stdin, &a[i])
      m = min(m, a[i])
    }

    dist := 0
    last := 0
    for i := 0; i < 2*n; i++ {
      if a[i%n] == m {
        dist = max(dist, i - last - 1)
        last = i
      }
    }

    fmt.Println(m*int64(n) + int64(dist))
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  paint := make([]int64, n)
  low, high := int64(1000) * 1000 * 1000, int64(1)
  start := 0
  var x int64
  for i := range paint {
    x = getI64()
    if x > high {
      high = x
    }
    if x < low {
      low = x
      start = i
    }
    paint[i] = x
  }
  if low == high {
    writer.WriteString(fmt.Sprintf("%d\n", low * int64(n)))
    return
  }
  count, best := 0, 0
  pos := start
  for {
    pos++
    if pos == n {
      pos = 0
    }
    if pos == start {
      break
    }
    if paint[pos] > low {
      count++
      if count > best {
        best = count
      }
    } else {
      count = 0
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", low * int64(n) + int64(best)))
}

package main

import (
    "bufio"
    "fmt"
    "os"
)

func min(a, b int64) int64 {
  if a < b {
    return a
  }
  return b
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n int

    fmt.Fscan(stdin, &n)
    a := make([]int64, n)
    m := int64(1000000001)
    for i := 0; i < n; i++ {
      fmt.Fscan(stdin, &a[i])
      m = min(m, a[i])
    }

    dist := 0
    last := 0
    for i := 0; i < 2*n; i++ {
      if a[i%n] == m {
        fmt.Println(">", i, last, i - last - 1)
        dist = max(dist, i - last - 1)
        last = i
      }
    }

    fmt.Println(m*int64(n) + int64(dist))
}

package main

import (
  "os"
  "bufio"
  "strconv"
  "fmt"
)

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  paint := make([]int, n)
  low, high := 1000 * 1000 * 1000, 1
  start := 0
  var x int
  for i := range paint {
    x = getI()
    if x > high {
      high = x
    }
    if x < low {
      low = x
      start = i
    }
    paint[i] = x
  }
  if low == high {
    writer.WriteString(fmt.Sprintf("%d\n", low * n))
    return
  }
  count, best := 0, 0
  pos := start
  for {
    pos++
    if pos == n {
      pos = 0
    }
    if pos == start {
      break
    }
    if paint[pos] > low {
      count++
      if count > best {
        best = count
      }
    } else {
      count = 0
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", low * n + best))
}


Polycarp likes numbers that are divisible by 3.He has a huge number $$$s$$$. Polycarp wants to cut from it the maximum number of numbers that are divisible by $$$3$$$. To do this, he makes an arbitrary number of vertical cuts between pairs of adjacent digits. As a result, after $$$m$$$ such cuts, there will be $$$m+1$$$ parts in total. Polycarp analyzes each of the obtained numbers and finds the number of those that are divisible by $$$3$$$.For example, if the original number is $$$s=3121$$$, then Polycarp can cut it into three parts with two cuts: $$$3|1|21$$$. As a result, he will get two numbers that are divisible by $$$3$$$.Polycarp can make an arbitrary number of vertical cuts, where each cut is made between a pair of adjacent digits. The resulting numbers cannot contain extra leading zeroes (that is, the number can begin with 0 if and only if this number is exactly one character '0'). For example, 007, 01 and 00099 are not valid numbers, but 90, 0 and 10001 are valid.What is the maximum number of numbers divisible by $$$3$$$ that Polycarp can obtain?

The first line of the input contains a positive integer $$$s$$$. The number of digits of the number $$$s$$$ is between $$$1$$$ and $$$2\cdot10^5$$$, inclusive. The first (leftmost) digit is not equal to 0.

Print the maximum number of numbers divisible by $$$3$$$ that Polycarp can get by making vertical cuts in the given number $$$s$$$.

NoteIn the first example, an example set of optimal cuts on the number is 3|1|21.In the second example, you do not need to make any cuts. The specified number 6 forms one number that is divisible by $$$3$$$.In the third example, cuts must be made between each pair of digits. As a result, Polycarp gets one digit 1 and $$$33$$$ digits 0. Each of the $$$33$$$ digits 0 forms a number that is divisible by $$$3$$$.In the fourth example, an example set of optimal cuts is 2|0|1|9|201|81. The numbers $$$0$$$, $$$9$$$, $$$201$$$ and $$$81$$$ are divisible by $$$3$$$.

package main

import (
	"bytes"
	. "fmt"
	"io/ioutil"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	s, _ := ioutil.ReadAll(os.Stdin)
	s = bytes.TrimSpace(s)
	n := len(s)
	for i, c := range s {
		s[i] = (c - '0') % 3
	}
	ans := 0
	for i := 0; i < n; i++ {
		if c := s[i]; c == 0 {
			ans++
		} else if i+1 < n {
			if c+s[i+1] == 3 {
				ans++
				i++
			} else if c == s[i+1] && i+2 < n {
				ans++
				i += 2
			}
		}
	}
	Print(ans)
}


You are given $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$n$$$ is odd. You are allowed to flip the sign of some (possibly all or none) of them. You wish to perform these flips in such a way that the following conditions hold:  At least $$$\frac{n - 1}{2}$$$ of the adjacent differences $$$a_{i + 1} - a_i$$$ for $$$i = 1, 2, \dots, n - 1$$$ are greater than or equal to $$$0$$$.  At least $$$\frac{n - 1}{2}$$$ of the adjacent differences $$$a_{i + 1} - a_i$$$ for $$$i = 1, 2, \dots, n - 1$$$ are less than or equal to $$$0$$$. Find any valid way to flip the signs. It can be shown that under the given constraints, there always exists at least one choice of signs to flip that satisfies the required condition. If there are several solutions, you can find any of them.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \le t \le 500$$$)  — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$3 \le n \le 99$$$, $$$n$$$ is odd)  — the number of integers given to you. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$-10^9 \le a_i \le 10^9$$$)  — the numbers themselves. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10000$$$.

For each test case, print $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$, corresponding to the integers after flipping signs. $$$b_i$$$ has to be equal to either $$$a_i$$$ or $$$-a_i$$$, and of the adjacent differences $$$b_{i + 1} - b_i$$$ for $$$i = 1, \dots, n - 1$$$, at least $$$\frac{n - 1}{2}$$$ should be non-negative and at least $$$\frac{n - 1}{2}$$$ should be non-positive. It can be shown that under the given constraints, there always exists at least one choice of signs to flip that satisfies the required condition. If there are several solutions, you can find any of them.

NoteIn the first test case, the difference $$$(-4) - (-2) = -2$$$ is non-positive, while the difference $$$3 - (-4) = 7$$$ is non-negative.In the second test case, we don't have to flip any signs. All $$$4$$$ differences are equal to $$$0$$$, which is both non-positive and non-negative.In the third test case, $$$7 - (-4)$$$ and $$$4 - (-6)$$$ are non-negative, while $$$(-4) - (-2)$$$ and $$$(-6) - 7$$$ are non-positive.

package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

var err error

func nextInt() (n int) {
	for {
		_, err = scanf("%v", &n)
		if err == nil {
			return n
		}
		if err.Error() == "EOF" {
			return 0
		}
	}
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	out = bufio.NewWriterSize(os.Stdout, 8192)
	defer out.Flush()
	if false {
		file, err := os.Open("b.in")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file, 8192)
	} else {
		in = bufio.NewReaderSize(os.Stdin, 8192)
	}

	t := nextInt()
	for ; t > 0; t-- {
		n := nextInt()
		for ; n > 0; n-- {
			if n%2 == 0 {
				printf("%d ", -abs(nextInt()))
			} else {
				printf("%d ", abs(nextInt()))
			}
		}
		printf("\n")
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scan(&t)
	for ; t >= 0; t-- {
		n := 0
		fmt.Scan(&n)
		for i := 0; i < n; i++ {
			var x float64
			fmt.Scan(&x)
			if i%2 == 0 {
				x = math.Abs(x)
			} else {
				x = -math.Abs(x)
			}
			fmt.Printf("%d ", int64(x))
		}
		fmt.Println()
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		solve(n, A)
		var buf bytes.Buffer
		for i := 0; i < n; i++ {
			buf.WriteString(fmt.Sprintf("%d ", A[i]))
		}
		fmt.Println(buf.String())
	}
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, A []int) {
	f := make([]int, n)
	f[0] = 1

	var a, b int
	for i := 1; i < n; i++ {
		f[i] = 1

		if A[i-1] == A[i] {
			continue
		}

		if A[i-1] < A[i] {
			if a > b {
				// 4, 5, 6 => -4, -5, 6
				// -3, -2, -1 => 3, 2, -1
				// -3, -2, 1 => 3, 2, 1
				if -A[i-1] < A[i] {
					// it is ok to just flip A[i-1]
					f[i-1] = -1
					a, b = b, a
				} else {
					// -A[i-1] > A[i], then after flip, b > a, and we need to incrase b, not correct, but we can flip before i - 2
					f[i-2] *= -1
					// to revert A[i-2] > A[i-1]
					a--
					a, b = b, a
					if f[i-2]*A[i-2] < A[i-1] {
						a++
					} else if f[i-2]*A[i-2] > A[i-1] {
						b++
					}
				}
			}
			a++
		} else {
			//A[i-1] > A[i]
			// 6, 5, 4
			// -1, -2, -3
			if b > a {
				if -A[i-1] > A[i] {
					f[i-1] = -1
					a, b = b, a
				} else {
					f[i-2] *= -1
					b--
					a, b = b, a
					if f[i-2]*A[i-2] < A[i-1] {
						a++
					} else if f[i-2]*A[i-2] > A[i-1] {
						b++
					}
				}
			}
			b++
		}
	}

	for i := n - 2; i >= 0; i-- {
		f[i] *= f[i+1]
		A[i] *= f[i]
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	tc := readNum(reader)

	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		solve(n, A)
		var buf bytes.Buffer
		for i := 0; i < n; i++ {
			buf.WriteString(fmt.Sprintf("%d ", A[i]))
		}
		fmt.Println(buf.String())
	}
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(n int, A []int) {

	for i := 0; i < n; i += 2 {
		if A[i] < 0 {
			A[i] = -A[i]
		}
		if i+1 < n && A[i+1] > 0 {
			A[i+1] = -A[i+1]
		}
	}
}

func solve1(n int, A []int) {
	f := make([]int, n)
	f[0] = 1

	var a, b int
	for i := 1; i < n; i++ {
		f[i] = 1

		if A[i-1] == A[i] {
			continue
		}

		if A[i-1] < A[i] {
			if a > b {
				// 4, 5, 6 => -4, -5, 6
				// -3, -2, -1 => 3, 2, -1
				// -3, -2, 1 => 3, 2, 1
				if -A[i-1] < A[i] {
					// it is ok to just flip A[i-1]
					f[i-1] = -1
					a, b = b, a
				} else {
					// -A[i-1] > A[i], then after flip, b > a, and we need to incrase b, not correct, but we can flip before i - 2
					f[i-2] *= -1
					// to revert A[i-2] > A[i-1]
					a--
					a, b = b, a
					if f[i-2]*A[i-2] < A[i-1] {
						a++
					} else if f[i-2]*A[i-2] > A[i-1] {
						b++
					}
				}
			}
			a++
		} else {
			//A[i-1] > A[i]
			// 6, 5, 4
			// -1, -2, -3
			if b > a {
				if -A[i-1] > A[i] {
					f[i-1] = -1
					a, b = b, a
				} else {
					f[i-2] *= -1
					b--
					a, b = b, a
					if f[i-2]*A[i-2] < A[i-1] {
						a++
					} else if f[i-2]*A[i-2] > A[i-1] {
						b++
					}
				}
			}
			b++
		}
	}

	for i := n - 2; i >= 0; i-- {
		f[i] *= f[i+1]
		A[i] *= f[i]
	}
}

package main

import (
    "fmt"
)

func main() {
    var t int
    fmt.Scan(&t)
    for t > 0 {
        t--
        solve()
    }
}

func solve() {
    var n int
    fmt.Scan(&n)
    a := make([]int, n)
    for i := 0; i < len(a); i++ {
        fmt.Scan(&a[i])
    }
    for i := 0; i < len(a); i++ {
        a[i] = abs(a[i])
        if i & 1 == 1 { a[i] *= -1 }
    }

    for i := 0; i < len(a); i++ {
        if i == 0 {
            fmt.Print(a[i])
        } else {
            fmt.Print(" ", a[i])
        }
    }
    fmt.Println()
}

func abs(x int) int {
    if x < 0 {return -x}
    return x
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		a := make([]int, n)
		for j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}

		for j := 0; j < n; j++ {
			if j == 0 {
				continue
			}

			if abs(a[j]) > abs(a[j-1]) {
				if (j%2 != 0 && a[j]-a[j-1] > 0) || (j%2 == 0 && a[j]-a[j-1] < 0) {
					a[j] = -a[j]
				}
			} else if abs(a[j]) <= abs(a[j-1]) {
				if (j%2 != 0 && a[j]-a[j-1] > 0) || (j%2 == 0 && a[j]-a[j-1] < 0) {
					a[j-1] = -a[j-1]
				}
			}
		}
		for j := 0; j < n; j++ {
			fmt.Print(a[j], " ")
		}
		fmt.Println()
	}
}

package main
import (
	"fmt"
	"math"
)
var a[100] float64
var t int

func main() {
	fmt.Scan(&t)
	for j := 0; j < t; j++ {
		var n int
		fmt.Scan(&n)
		for i := 0; i < n; i++ {
			fmt.Scan(&a[i])
			a[i] = math.Abs(a[i])
			if i % 2 == 1 {
				a[i] = -a[i]
			}
			fmt.Printf("%d ", int64(a[i]))
		}
		fmt.Println()
	}

}

package main

import (
	"fmt"
	"math"
)

func main() {
	var t int
	fmt.Scan(&t)
	for ; t >= 0; t-- {
		n := 0
		fmt.Scan(&n)
		for i := 0; i < n; i++ {
			var x float64
			fmt.Scan(&x)
			if i%2 == 0 {
				x = math.Abs(float64(x))
			} else {
				x = -math.Abs(float64(x))
			}
			fmt.Print(x + ' ')
		}
		fmt.Println()
	}
}


Monocarp wrote down two numbers on a whiteboard. Both numbers follow a specific format: a positive integer $$$x$$$ with $$$p$$$ zeros appended to its end.Now Monocarp asks you to compare these two numbers. Can you help him?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains two integers $$$x_1$$$ and $$$p_1$$$ ($$$1 \le x_1 \le 10^6; 0 \le p_1 \le 10^6$$$) — the description of the first number. The second line of each testcase contains two integers $$$x_2$$$ and $$$p_2$$$ ($$$1 \le x_2 \le 10^6; 0 \le p_2 \le 10^6$$$) — the description of the second number.

For each testcase print the result of the comparison of the given two numbers. If the first number is smaller than the second one, print '<'. If the first number is greater than the second one, print '>'. If they are equal, print '='.

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)
	var (
		n, p1, p2 int
		in1, in2 string
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		d, e := len(in1) + p1, len(in2) + p2

		if d > e {
			writer.WriteString(">\n")
		} else if e > d {
			writer.WriteString("<\n")
		} else {
			for len(in1) > len(in2) {
				in2 += "0"
			}

			for len(in1) < len(in2) {
				in1 += "0"
			}

			if in1 > in2 {
				writer.WriteString(">\n")
			} else if in2 > in1 {
				writer.WriteString("<\n")
			} else {
				writer.WriteString("=\n")
			}
		}
	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var a, p1 int
		fmt.Fscan(in, &a, &p1)

		var b, p2 int
		fmt.Fscan(in, &b, &p2)

		s1 := fmt.Sprintf("%d", a)
		s2 := fmt.Sprintf("%d", b)

		if len(s1)+p1 < len(s2)+p2 {
			fmt.Fprintln(out, "<")
		} else if len(s1)+p1 > len(s2)+p2 {
			fmt.Fprintln(out, ">")
		} else {
			limit := len(s1)
			if len(s2) < limit {
				limit = len(s2)
			}

			var d int
			for i := 0; i < limit; i++ {
				if s1[i] > s2[i] {
					d = 1
					break
				} else if s1[i] < s2[i] {
					d = -1
					break
				}
			}

			if d == 0 {
				if len(s1) > len(s2) {
					for i := limit; i < len(s1); i++ {
						if s1[i] > '0' {
							d = 1
						}
					}
				} else if len(s2) > len(s1) {
					for i := limit; i < len(s2); i++ {
						if s2[i] > '0' {
							d = -1
						}
					}
				}
			}

			if d > 0 {
				fmt.Fprintln(out, ">")
			} else if d < 0 {
				fmt.Fprintln(out, "<")
			} else {
				fmt.Fprintln(out, "=")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	reader            = bufio.NewReader(os.Stdin)
	t, x1, x2, p1, p2 int
)

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func pow10(x int) int64 {
	k := int64(1)
	for ; x > 0; x-- {
		k *= 10
	}
	return k
}

func solve(x1, p1, x2, p2 int) string {
	if p1-p2 > 6 {
		return ">"
	}
	if p2-p1 > 6 {
		return "<"
	}
	p1, p2 = p1-min(p1, p2), p2-min(p1, p2)
	v1, v2 := int64(x1)*pow10(p1), int64(x2)*pow10(p2)
	if v1 > v2 {
		return ">"
	}
	if v1 < v2 {
		return "<"
	}
	return "="
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &x1, &p1, &x2, &p2)
		fmt.Println(solve(x1, p1, x2, p2))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	reader            = bufio.NewReader(os.Stdin)
	t, x1, x2, p1, p2 int
)

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func solve(x1, p1, x2, p2 int) string {
	if p1-p2 > 6 {
		return ">"
	}
	if p2-p1 > 6 {
		return "<"
	}
	p1, p2 = p1-min(p1, p2), p2-min(p1, p2)
	v1, v2 := int64(x1)*int64(math.Pow10(p1)), int64(x2)*int64(math.Pow10(p2))
	if v1 > v2 {
		return ">"
	}
	if v1 < v2 {
		return "<"
	}
	return "="
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &x1, &p1, &x2, &p2)
		fmt.Println(solve(x1, p1, x2, p2))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	reader            = bufio.NewReader(os.Stdin)
	t, x1, x2, p1, p2 int
)

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func solve(x1, p1, x2, p2 int) string {
	if p1-p2 > 6 {
		return ">"
	}
	if p2-p1 > 6 {
		return "<"
	}
	d := min(p1, p2)
	p1 -= d
	p2 -= d
	v1, v2 := int64(x1)*int64(math.Pow10(p1)), int64(x2)*int64(math.Pow10(p2))
	if v1 > v2 {
		return ">"
	}
	if v1 < v2 {
		return "<"
	}
	return "="
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &x1, &p1, &x2, &p2)
		fmt.Println(solve(x1, p1, x2, p2))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		x1, x2, p1, p2 := 0.0, 0.0, 0.0, 0.0
		fmt.Fscan(f, &x1, &p1)
		fmt.Fscan(f, &x2, &p2)
		a, b := math.Log10(x1)+p1, math.Log10(x2)+p2
		if a-b > 1e-9 {
			fmt.Fprintln(w, ">")
		} else if a-b < -1e-9 {
			fmt.Fprintln(w, "<")
		} else {
			fmt.Fprintln(w, "=")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main(){
	var t uint16
	var x1, p1, x2, p2 uint32
	r := bufio.NewReader(os.Stdin)
	fmt.Fscanf(r, "%v\n", &t)
	var i uint16
	for i=0; i<t; i++{
		fmt.Fscanf(r, "%v %v\n%v %v\n", &x1, &p1, &x2, &p2)
		if p1 < p2{
			p1, p2 = 0, p2-p1
		} else {
			p2, p1 = 0, p1-p2
		}
		if p1 >= 7 {
			fmt.Println(">")
		} else if p2 >= 7 {
			fmt.Println("<")
		} else {
			if x1*uint32(math.Pow(10, float64(p1))) < x2*uint32(math.Pow(10, float64(p2))) {
				fmt.Println("<")
			} else if  x1*uint32(math.Pow(10, float64(p1))) > x2*uint32(math.Pow(10, float64(p2))){
				fmt.Println(">")
			} else {
				fmt.Println("=")
			}
		}
	}
}

package main

import (
	"fmt"
)

const eps = 1e-9

func cmp(x float64) int {
	if x > eps {
		return 1
	} else if x < -eps {
		return -1
	} else {
		return 0
	}
}

func solve() {
	var x1, p1, x2, p2 int
	fmt.Scan(&x1, &p1, &x2, &p2)
	if x1 == x2 && p1 == p2 {
		fmt.Println("=")
		return
	}
	var y1, y2 float64
	y1 = float64(x1)
	y2 = float64(x2)
	for i := 0; i < p1-p2 && cmp(y2) != 0; i++ {
		y2 /= 10
	}
	for i := 0; i < p2-p1 && cmp(y1) != 0; i++ {
		y1 /= 10
	}
	ret := cmp(y1 - y2)
	if ret == 1 {
		fmt.Println(">")
	} else if ret == 0 {
		fmt.Println("=")
	} else {
		fmt.Println("<")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for k := 0; k < t; k++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		t -= 1
		var x1, p1, x2, p2 int
		fmt.Fscan(in, &x1, &p1, &x2, &p2)
		var first, second = strconv.Itoa(x1), strconv.Itoa(x2)

		if len(first) + p1 < len(second) + p2 {
			fmt.Println("<")
			continue
		} else if len(first) + p1 > len(second) + p2 {
			fmt.Println(">")
			continue
		}

		if len(first) < len(second){
			for len(first) != len(second){
				first += "0"
			}
		}else{
			for len(first) != len(second){
				second += "0"
			}
		}

		if first < second {
			fmt.Println("<")
		} else if first > second {
			fmt.Println(">")
		} else {
			fmt.Println("=")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strings"
)

/*
3
4 2
2 4
2 3
5 1
100 0
1 2
---
<
>
=
*/

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	bld := strings.Builder{}

	var t = 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		var x1, p1, x2, p2 int
		scanf("%d %d\n %d %d\n", &x1, &p1, &x2, &p2)

		lenN1 := int(math.Log10(float64(x1))) + 1
		lenN2 := int(math.Log10(float64(x2))) + 1

		fx1 := float64(x1)
		fx2 := float64(x2)

		if lenN1 < lenN2 {
			fx2 /= math.Pow10(lenN2 - lenN1)
			p2 += lenN2 - lenN1
		} else {
			fx1 /= math.Pow10(lenN1 - lenN2)
			p1 += lenN1 - lenN2
		}

		var cmpRes int

		if p1 == p2 {
			if fx1 < fx2 {
				cmpRes = -1
			} else if fx1 > fx2 {
				cmpRes = 1
			}
		} else {
			if p1 < p2 {
				cmpRes = -1
			} else if p1 > p2 {
				cmpRes = 1
			}
		}

		switch cmpRes {
		case -1:
			fmt.Fprintln(&bld, "<")
		case 0:
			fmt.Fprintln(&bld, "=")
		case 1:
			fmt.Fprintln(&bld, ">")
		}
	}

	printf("%s", bld.String())
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

//goland:noinspection GoUnusedType
type pair struct {
	x int64
	y int64
}

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//goland:noinspection GoUnusedFunction
func printf(f string, a ...interface{}) {
	if _, err := fmt.Fprintf(writer, f, a...); err != nil {
		panic(err)
	}
}

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

//goland:noinspection GoUnusedFunction
func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//goland:noinspection GoUnusedFunction
func isPrime(n int) bool {
	if n == 2 || n == 3 {
		return true
	}

	if n <= 1 || n%2 == 0 || n%3 == 0 {
		return false
	}

	for i := 5; i*i <= n; i += 6 {
		if n%i == 0 || n%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

// 从控制台读取输入:
package main
import "fmt"

var (
	T int
	x1,x2,p1,p2 int
)

func GetNumLen(num int) int {
	var cnt = 1;
	for num > 0 {
		cnt ++
		num /= 10
	}
	return cnt
}

func pow( a , b int) int {
	ans := 1
	for i := 0 ; i < b ; i ++ {
		ans *= a
	}
	return ans
}

func main() {

	_ , _ = fmt.Scanln(&T)
	for i := 0 ; i < T ; i ++ {
		_ , _ = fmt.Scanln(&x1,&p1)
		_ , _ = fmt.Scanln(&x2,&p2)
		if GetNumLen(x1) + p1 == GetNumLen(x2) + p2 {
			if x1 > x2 {
				x2 *= pow(10,GetNumLen(x1)-GetNumLen(x2))
			}else{
				x1 *= pow(10,GetNumLen(x2)-GetNumLen(x1))
			}

			if x1 == x2 {
				fmt.Println("=")
			} else if x1 > x2 {
				fmt.Printf("%c\n",'>')
			}else {
				fmt.Printf("%c\n",'<')
			}
		}else{
			if GetNumLen(x1) + p1 > GetNumLen(x2) + p2 {
				fmt.Printf("%c\n",'>')
			} else {
				fmt.Printf("%c\n",'<')
			}
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"time"
)

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func MAXX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		var l, q int64
		l = MAX(x, y)
		q = MIN(x, y)
		var m int64
		for l*q > 0 {
			a := l % q
			b := l - a
			cc := int64(b / q)
			remain := l - cc*q
			l = MAX(remain, q)
			q = MIN(remain, q)
			if l*q == 0 {
				m = l + q
				break
			}

		}
		return m
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

func ABS(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}

func DIVI(x []int) string {
	if len(x) == 1 {
		if x[0]%2 == 0 {
			return "NO"
		} else {
			return "YES"

		}
	} else {
		q := len(x)
		if DIVI(x[:q-1]) == "YES" {
			b := 0
			for j := 2; j < q+2; j++ {
				if x[q-1]%j != 0 {
					b = 1
					break
				}
			}
			if b == 1 {
				return "YES"
			} else {
				return "NO"

			}
		} else {
			return "NO"
		}
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var x1, x2 string
		var p1, p2 int
		fmt.Fscan(input, &x1, &p1, &x2, &p2)

		first := len(x1) + p1
		second := len(x2) + p2

		if first > second {
			fmt.Println(">")
		}
		if first < second {
			fmt.Println("<")
		}

		if first == second {
			t1 := p1 - MINN(p1, p2)
			t2 := p2 - MINN(p1, p2)
			for i := 1; i <= t1; i++ {
				x1 = x1 + "0"
			}
			for i := 1; i <= t2; i++ {
				x2 = x2 + "0"
			}

			// sort.Strings(array)
			// f := 0
			// s := 0
			// if array[o] == x1 {
			// 	f++
			// }
			// if array[0] == x2 {
			// 	s++
			// }
			// if f+s == 2 {
			// 	fmt.Println("=")
			// } else {
			// 	if f == 1 {
			// 		fmt.Println("<")
			// 	} else {
			// 		fmt.Println(">")

			// 	}
			// }

			if x1 > x2 {
				fmt.Println(">")
			}
			if x1 < x2 {
				fmt.Println("<")

			}
			if x1 == x2 {
				fmt.Println("=")

			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	defer _w.Flush()
	t := ReadInt()
	for i := 0; i < t; i++ {
		solve()
	}
}
func solve() {
	s1, p1 := ReadString(), ReadInt()
	s2, p2 := ReadString(), ReadInt()

	f1, f2 := f(s1, p1), f(s2, p2)
	if f1 != f2 {
		if f1 < f2 {
			println("<")
		} else {
			println(">")
		}
		return
	}

	if len(s1) < len(s2) {
		s1 += strings.Repeat("0", len(s2)-len(s1))
	} else {
		s2 += strings.Repeat("0", len(s1)-len(s2))
	}

	if s1 < s2 {
		println("<")
	} else if s1 == s2 {
		println("=")
	} else {
		println(">")
	}
}
func f(x string, p int) int {
	return len(x) + p
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func ReadString() (s string) { fmt.Fscan(_r, &s); return }
func ReadInt() (i int)       { fmt.Fscan(_r, &i); return }
func ReadInts(n int) (a []int) {
	for ; n > 0; n-- {
		a = append(a, ReadInt())
	}
	return
}
func print(a ...interface{})   { fmt.Fprint(_w, a...) }
func println(a ...interface{}) { fmt.Fprintln(_w, a...) }
func prints(s []int)           { v := fmt.Sprint(s); println(v[1 : len(v)-1]) }

// 1613A. Long Comparison
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var T int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &T)
	for t := 1; t <= T; t++ {
		var x1, p1, x2, p2 int
		fmt.Fscan(reader, &x1, &p1, &x2, &p2)
		digits1 := len(strconv.Itoa(x1)) + p1
		digits2 := len(strconv.Itoa(x2)) + p2
		if digits1 < digits2 {
			fmt.Println("<")
		} else if digits1 > digits2 {
			fmt.Println(">")
		} else {
			for len(strconv.Itoa(x1)) != len(strconv.Itoa(x2)) {
				if x1 < x2 {
					x1 = x1 * 10
				} else {
					x2 = x2 * 10
				}
			}
			if x1 < x2 {
				fmt.Println("<")
			} else if x1 > x2 {
				fmt.Println(">")
			} else {
				fmt.Println("=")
			}
		}

	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func main() {
	var ntc int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		var aint, bint, a0, b0 int
		fmt.Fscan(in, &aint, &a0, &bint, &b0)
		var astr = strconv.Itoa(aint)
		var bstr = strconv.Itoa(bint)
		if len(astr)+a0 != len(bstr)+b0 {
			if len(astr)+a0 < len(bstr)+b0 {
				fmt.Fprintln(out, "<")
			} else {
				fmt.Fprintln(out, ">")
			}
		} else {
			for ; a0 < b0; b0-- {
				bint *= 10
			}
			for ; a0 > b0; a0-- {
				aint *= 10
			}
			if aint == bint {
				fmt.Fprintln(out, "=")
			} else if aint < bint {
				fmt.Fprintln(out, "<")
			} else {
				fmt.Fprintln(out, ">")
			}
		}
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	defer out.Flush()

	var tc int
	for fmt.Fscan(in, &tc); tc > 0; tc-- {
		var x1, x2 string
		var p1, p2 int
		fmt.Fscan(in, &x1, &p1, &x2, &p2)
		p1, p2 = p1-min(p1, p2), p2-min(p1, p2)
		for len(x1) < len(x2) && p1 > 0 {
			x1 += "0"
			p1--
		}
		for len(x2) < len(x1) && p2 > 0 {
			x2 += "0"
			p2--
		}
		l1, l2 := len(x1)+p1, len(x2)+p2
		d := l1 - l2
		if l1 == l2 {
			d = strings.Compare(x1, x2)
		}
		if d < 0 {
			fmt.Fprintln(out, "<")
		} else if d > 0 {
			fmt.Fprintln(out, ">")
		} else {
			fmt.Fprintln(out, "=")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scan() string {
	for sc.Scan() {
		break
	}
	return sc.Text()
}

func scanInt() int {
	i, err := strconv.Atoi(scan())
	if err != nil {
		panic(err)
	}
	return i
}

func scanInt8() int8 {
	i, err := strconv.ParseInt(scan(), 10, 8)
	if err != nil {
		panic(err)
	}
	return int8(i)
}

func scanInt64() int64 {
	i, err := strconv.ParseInt(scan(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(ints ...int) int {
	a := ints[0]
	n := len(ints)
	for i := 1; i < n; i++ {
		if ints[i] < a {
			a = ints[i]
		}
	}
	return a
}

func max(ints ...int) int {
	a := ints[0]
	n := len(ints)
	for i := 1; i < n; i++ {
		if ints[i] > a {
			a = ints[i]
		}
	}
	return a
}

func proc() {
	x1, p1 := scanInt(), scanInt()
	x2, p2 := scanInt(), scanInt()
	s1, s2 := fmt.Sprintf("%d", x1), fmt.Sprintf("%d", x2)
	l1, l2 := len(s1), len(s2)
	n1, n2 := l1+p1, l2+p2
	if n1 < n2 {
		fmt.Println("<")
	} else if n1 > n2 {
		fmt.Println(">")
	} else {
		for l1 < l2 {
			l1++
			s1 += "0"
		}
		for l2 < l1 {
			l2++
			s2 += "0"
		}
		x1, _ = strconv.Atoi(s1)
		x2, _ = strconv.Atoi(s2)
		if x1 < x2 {
			fmt.Println("<")
		} else if x1 > x2 {
			fmt.Println(">")
		} else {
			fmt.Println("=")
		}
	}
}

func main() {
	sc.Split(bufio.ScanWords)
	t := scanInt()
	for i := 0; i < t; i++ {
		proc()
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		mn := int(math.Min(float64(p2), float64(p1)))
		p1 -= mn
		p2 -= mn
		if p1 >= 7 {
			writer.WriteString(">\n")
		} else if p2 >= 7 {
			writer.WriteString("<\n")
		} else {
			if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
				writer.WriteString(">\n")
			} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
				writer.WriteString("<\n")

			} else {
				writer.WriteString("=\n")

			}
		}

	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		mn := int(math.Min(float64(p2), float64(p1)))
		p1 -= mn
		p2 -= mn
		if p1 >= 7 {
			writer.WriteString("<\n")
		} else if p2 >= 7 {
			writer.WriteString(">\n")
		} else {
			if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
				writer.WriteString(">\n")
			} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
				writer.WriteString("<\n")

			} else {
				writer.WriteString("=\n")

			}
		}

	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		mn := int(math.Min(float64(p2), float64(p1)))
		p1 -= mn
		p2 -= mn
		if p1 >= 7 {
			writer.WriteString("<\n")
		}
		if p2 >= 7 {
			writer.WriteString(">\n")
		}
		if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString(">\n")
		} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString("<\n")

		} else {
			writer.WriteString("=\n")

		}
	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		mn := int(math.Min(float64(p2), float64(p1)))
		p1 -= mn
		p2 -= mn
		if p1 >= 7 {
			writer.WriteString("<\n")
		} else if p2 >= 7 {
			writer.WriteString(">\n")
		}
		if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString(">\n")
		} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString("<\n")

		} else {
			writer.WriteString("=\n")

		}
	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString(">\n")
		} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString("<\n")

		} else {
			writer.WriteString("=\n")

		}
	}

	writer.Flush()
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&in1)
		fmt.Scan(&p1)
		fmt.Scan(&in2)
		fmt.Scan(&p2)
		if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
			fmt.Println(">")
		} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
			fmt.Println("<")
		} else {
			fmt.Println("=")
		}
	}
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf( "%d %d", &in1, &p1)
		fmt.Scanf( "%d %d", &in2, &p2)
		if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
			fmt.Println(">")
		} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
			fmt.Println("<")
		} else {
			fmt.Println("=")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	writer := bufio.NewWriter(os.Stdout)

	var (
		n, in1, in2, p1, p2 int
	)

	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf( "%d %d", &in1, &p1)
		fmt.Scanf( "%d %d", &in2, &p2)
		if in1 * int(math.Pow(float64(10), float64(p1))) > in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString(">\n")
		} else if in1 * int(math.Pow(float64(10), float64(p1))) < in2 * int(math.Pow(float64(10), float64(p2))) {
			writer.WriteString("<\n")
		} else {
			writer.WriteString("=\n")
		}
	}

	writer.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var a, p1 int
		fmt.Fscan(in, &a, &p1)

		var b, p2 int
		fmt.Fscan(in, &b, &p2)

		s1 := fmt.Sprintf("%d", a)
		s2 := fmt.Sprintf("%d", b)

		if len(s1)+p1 < len(s2)+p2 {
			fmt.Fprintln(out, "<")
		} else if len(s1)+p1 > len(s2)+p2 {
			fmt.Fprintln(out, ">")
		} else {
			limit := len(s1)
			if len(s2) < limit {
				limit = len(s2)
			}

			var d int
			for i := 0; i < limit; i++ {
				if s1[i] > s2[i] {
					d = 1
				} else if s1[i] < s2[i] {
					d = -1
				}
			}

			if d == 0 {
				if len(s1) > len(s2) {
					for i := limit; i < len(s1); i++ {
						if s1[i] > '0' {
							d = 1
						}
					}
				} else if len(s2) > len(s1) {
					for i := limit; i < len(s2); i++ {
						if s2[i] > '0' {
							d = -1
						}
					}
				}
			}

			if d > 0 {
				fmt.Fprintln(out, ">")
			} else if d < 0 {
				fmt.Fprintln(out, "<")
			} else {
				fmt.Fprintln(out, "=")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var a, p1 int
		fmt.Fscan(in, &a, &p1)

		var b, p2 int
		fmt.Fscan(in, &b, &p2)

		s1 := fmt.Sprintf("%d", a)
		s2 := fmt.Sprintf("%d", b)

		if len(s1)+p1 < len(s2)+p2 {
			fmt.Fprintln(out, "<")
		} else if len(s1)+p1 > len(s2)+p2 {
			fmt.Fprintln(out, ">")
		} else {
			var d int
			for i := range s1 {
				if i > len(s2)-1 {
					if s1[i] > '0' {
						d = 1
					}
					break
				}

				if s1[i] > s2[i] {
					d = 1
					break
				} else if s1[i] < s2[i] {
					d = -1
					break
				}
			}

			if d > 0 {
				fmt.Fprintln(out, ">")
			} else if d < 0 {
				fmt.Fprintln(out, "<")
			} else if len(s2) > len(s1) && s2[len(s2)-1] > '0' {
				fmt.Fprintln(out, "<")
			} else {
				fmt.Fprintln(out, "=")
			}
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var (
	reader            = bufio.NewReader(os.Stdin)
	t, x1, x2, p1, p2 int
)

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func solve(x1, p1, x2, p2 int) string {
	if p1-p2 > 6 {
		return ">"
	}
	if p2-p1 > 6 {
		return "<"
	}
	p1 -= min(p1, p2)
	p2 -= min(p1, p2)
	v1, v2 := int64(x1)*int64(math.Pow10(p1)), int64(x2)*int64(math.Pow10(p2))
	if v1 > v2 {
		return ">"
	}
	if v1 < v2 {
		return "<"
	}
	return "="
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &x1, &p1, &x2, &p2)
		fmt.Println(solve(x1, p1, x2, p2))
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		x1, x2, p1, p2 := 0.0, 0.0, 0.0, 0.0
		fmt.Fscan(f, &x1, &p1)
		fmt.Fscan(f, &x2, &p2)
		a, b := int64(math.Log10(x1)+p1), int64(math.Log10(x2)+p2)
		if a < b {
			fmt.Fprintln(w, "<")
		} else if a > b {
			fmt.Fprintln(w, ">")
		} else {
			fmt.Fprintln(w, "=")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		x1, x2, p1, p2 := 0.0, 0.0, 0.0, 0.0
		fmt.Fscan(f, &x1, &p1)
		fmt.Fscan(f, &x2, &p2)
		a, b := math.Log10(x1)+p1, math.Log10(x2)+p2
		if a < b {
			fmt.Fprintln(w, "<")
		} else if a > b {
			fmt.Fprintln(w, ">")
		} else {
			fmt.Fprintln(w, "=")
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main(){
	var t uint16
	var x1, p1, x2, p2 uint32
	r := bufio.NewReader(os.Stdin)
	fmt.Fscanf(r, "%v\n", &t)
	var i uint16
	for i=0; i<t; i++{
		fmt.Fscanf(r, "%v %v\n%v %v\n", &x1, &p1, &x2, &p2)
		if p1 < p2{
			p1, p2 = 0, p2-p1
		} else {
			p2, p1 = 0, p1-p2
		}
		if x1*uint32(math.Pow(10, float64(p1))) < x2*uint32(math.Pow(10, float64(p2))) {
			fmt.Println("<")
		} else if  x1*uint32(math.Pow(10, float64(p1))) > x2*uint32(math.Pow(10, float64(p2))){
			fmt.Println(">")
		} else {
			fmt.Println("=")
		}
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main(){
	var t uint16
	var x1, p1, x2, p2 uint32
	r := bufio.NewReader(os.Stdin)
	fmt.Fscanf(r, "%v\n", &t)
	var i uint16
	for i=0; i<=t; i++{
		fmt.Fscanf(r, "%v %v\n%v %v\n", &x1, &p1, &x2, &p2)
		if p1 < p2{
			p1, p2 = 0, p2-p1
		} else {
			p2, p1 = 0, p1-p2
		}
		if x1*uint32(math.Pow(10, float64(p1))) < x2*uint32(math.Pow(10, float64(p2))) {
			fmt.Println("<")
		} else if  x1*uint32(math.Pow(10, float64(p1))) > x2*uint32(math.Pow(10, float64(p2))){
			fmt.Println(">")
		} else {
			fmt.Println("=")
		}
	}
}

package main

import (
	"fmt"
)

const eps = 1e-9

func cmp(x float64) int {
	if x > eps {
		return 1
	} else if x < -eps {
		return -1
	} else {
		return 0
	}
}

func solve() {
	var x1, p1, x2, p2 int
	fmt.Scan(&x1, &p1, &x2, &p2)
	if x1 == x2 && p1 == p2 {
		println("=")
		return
	}
	var y1, y2 float64
	y1 = float64(x1)
	y2 = float64(x2)
	for i := 0; i < p1-p2 && cmp(y2) != 0; i++ {
		y2 /= 10
	}
	for i := 0; i < p2-p1 && cmp(y1) != 0; i++ {
		y1 /= 10
	}
	ret := cmp(y1 - y2)
	if ret == 1 {
		println(">")
	} else if ret == 0 {
		println("=")
	} else {
		println("<")
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for k := 0; k < t; k++ {
		solve()
	}
}

package main

import (
	"fmt"
)

const eps = 1e-9

func cmp(x float64) int {
	if x > eps {
		return 1
	} else if x < -eps {
		return -1
	} else {
		return 0
	}
}

func solve() {
	var x1, p1, x2, p2 int
	fmt.Scanf("%d%d\n%d%d\n", &x1, &p1, &x2, &p2)
	if x1 == x2 && p1 == p2 {
		println("=")
		return
	}
	var y1, y2 float64
	y1 = float64(x1)
	y2 = float64(x2)
	for i := 0; i < p1-p2 && cmp(y2) != 0; i++ {
		y2 /= 10
	}
	for i := 0; i < p2-p1 && cmp(y1) != 0; i++ {
		y1 /= 10
	}
	ret := cmp(y1 - y2)
	if ret == 1 {
		println(">")
	} else if ret == 0 {
		println("=")
	} else {
		println("<")
	}
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for k := 0; k < t; k++ {
		solve()
	}
}

// 从控制台读取输入:
package main
import "fmt"

var (
	T int
	x1,x2,p1,p2 int
)

func GetNumLen(num int) int {
	var cnt = 1;
	for num > 0 {
		cnt ++
		num /= 10
	}
	return cnt
}

func pow( a , b int) int {
	ans := 1
	for i := 0 ; i < b ; i ++ {
		ans *= a
	}
	return ans
}

func main() {

	_ , _ = fmt.Scanln(&T)
	for i := 0 ; i < T ; i ++ {
		_ , _ = fmt.Scanln(&x1,&p1)
		_ , _ = fmt.Scanln(&x2,&p2)
		fmt.Println(x1,p1,x2,p2)
		if GetNumLen(x1) + p1 == GetNumLen(x2) + p2 {
			if x1 > x2 {
				x2 *= pow(10,GetNumLen(x1)-GetNumLen(x2))
			}else{
				x1 *= pow(10,GetNumLen(x2)-GetNumLen(x1))
			}

			if x1 == x2 {
				fmt.Println("=")
			} else if x1 > x2 {
				fmt.Printf("%c\n",'>')
			}else {
				fmt.Printf("%c\n",'<')
			}
		}else{
			if GetNumLen(x1) + p1 > GetNumLen(x2) + p2 {
				fmt.Printf("%c\n",'>')
			} else {
				fmt.Printf("%c\n",'<')
			}
		}
	}

}