package main import ( "fmt" "sort" ) func main() { var n int fmt.Scan(&n) fa := make([][2]int, n) for i := 0; i < n; i++ { fmt.Scan(&fa[i][0], &fa[i][1]) } sort.SliceStable(fa, func(i, j int) bool { return fa[i][0]*fa[j][1] > fa[j][0]*fa[i][1] }) for _, v := range fa { fmt.Printf("%d %d\n", v[0], v[1]) } }