/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-07 20:25]
*     Last Modified       :     [2014-03-07 21:49]
*     Description         :
**********************************************************************************/

package main

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

const inf = 0x3fffffff

var (
    n, m, k        int
    c, grp, parent []int
    g              [][]int
)

func AddEdge(a, b, c int) {
    g[a][b] = MyInt(g[a][b]).Min(c)
    g[b][a] = MyInt(g[b][a]).Min(c)
}

func GetParent(x int) int {
    px := x
    for parent[px] != px {
        px = parent[px]
    }
    for parent[x] != x {
        x, parent[x] = parent[x], px
    }
    return px
}

func Union(a, b int) {
    pa, pb := GetParent(a), GetParent(b)
    if pa != pb {
        parent[pa] = pb
    }
}

func Check() bool {
    c[k] = n + 1
    for i := 0; i < k; i++ {
        p := GetParent(c[i])
        for j := c[i] + 1; j < c[i+1]; j++ {
            if p != GetParent(j) {
                return false
            }
        }
    }
    return true
}

func Spfa(s int, dst []int) {
    var q = make(chan int, k)
    var inq = make([]bool, k)
    for i := 0; i < k; i++ {
        dst[i] = inf
    }
    q <- s
    inq[s] = true
    dst[s] = 0
    for len(q) != 0 {
        f := <-q
        inq[f] = false
        for i := 0; i < k; i++ {
            if g[f][i] < inf && dst[f]+g[f][i] < dst[i] {
                dst[i] = dst[f] + g[f][i]
                if !inq[i] {
                    q <- i
                    inq[i] = true
                }
            }
        }
    }
}

func SpfaAndPrint() {
    var d = make([][]int, k)
    for i := 0; i < k; i++ {
        d[i] = make([]int, k)
        Spfa(i, d[i][:])
        for j := 0; j < k; j++ {
            if j > 0 {
                fmt.Print(" ")
            }
            if d[i][j] >= inf {
                d[i][j] = -1
            }
            fmt.Print(d[i][j])
        }
        fmt.Println()
    }
}

func main() {
    scanner.Split(bufio.ScanWords)

    scanner.NextInts(&n, &m, &k)
    c, grp, parent = make([]int, k+1), make([]int, n+1), make([]int, n+1)
    g = make([][]int, k)
    for i, j := 0, 1; i < k; i++ {
        c[i], j = j, scanner.NextInt()+j
        for l := c[i]; l < j; l++ {
            grp[l], parent[l] = i, l
        }
        g[i] = make([]int, k)
        for l := 0; l < k; l++ {
            g[i][l] = inf
        }
    }
    for i := 0; i < m; i++ {
        var u, v, x int
        scanner.NextInts(&u, &v, &x)
        AddEdge(grp[u], grp[v], x)
        if x == 0 {
            Union(u, v)
        }
    }
    if Check() {
        fmt.Println("Yes")
        SpfaAndPrint()
    } else {
        fmt.Println("No")
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInts(args ...*int) {
    for _, v := range args {
        *v = self.NextInt()
    }
}

type MyInt int

func (self MyInt) Min(x int) int {
    if int(self) < x {
        return int(self)
    }
    return x
}

/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-07 20:25]
*     Last Modified       :     [2014-03-07 22:14]
*     Description         :
**********************************************************************************/

package main

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

const inf = 0x3fffffff

var (
    n, m, k        int
    c, grp, parent []int
    g              [][]int
    q              chan int
    inq            []bool
)

func AddEdge(a, b, c int) {
    g[a][b] = MyInt(g[a][b]).Min(c)
    g[b][a] = g[a][b]
}

func GetParent(x int) int {
    if x != parent[x] {
        parent[x] = GetParent(parent[x])
    }
    return parent[x]
}

func Union(a, b int) {
    pa, pb := GetParent(a), GetParent(b)
    if pa != pb {
        parent[pa] = pb
    }
}

func Check() bool {
    c[k] = n + 1
    for i := 0; i < k; i++ {
        p := GetParent(c[i])
        for j := c[i] + 1; j < c[i+1]; j++ {
            if p != GetParent(j) {
                return false
            }
        }
    }
    return true
}

func Spfa(s int, dst []int) {
    for i := 0; i < k; i++ {
        dst[i] = inf
    }
    q <- s
    inq[s] = true
    dst[s] = 0
    for len(q) != 0 {
        f := <-q
        inq[f] = false
        for i := 0; i < k; i++ {
            if dst[f]+g[f][i] < dst[i] {
                dst[i] = dst[f] + g[f][i]
                if !inq[i] {
                    q <- i
                    inq[i] = true
                }
            }
        }
    }
}

func SpfaAndPrint() {
    var d = make([][]int, k)
    for i := 0; i < k; i++ {
        d[i] = make([]int, k)
        Spfa(i, d[i][:])
        for j := 0; j < k; j++ {
            if j > 0 {
                fmt.Print(" ")
            }
            if d[i][j] >= inf {
                d[i][j] = -1
            }
            fmt.Print(d[i][j])
        }
        fmt.Println()
    }
}

func main() {
    scanner.Split(bufio.ScanWords)

    scanner.NextInts(&n, &m, &k)
    c, grp, parent = make([]int, k+1), make([]int, n+1), make([]int, n+1)
    g = make([][]int, k)
    q = make(chan int, k)
    inq = make([]bool, k)
    for i, j := 0, 1; i < k; i++ {
        c[i], j = j, scanner.NextInt()+j
        for l := c[i]; l < j; l++ {
            grp[l], parent[l] = i, l
        }
        g[i] = make([]int, k)
        for l := 0; l < k; l++ {
            g[i][l] = inf
        }
    }
    for i := 0; i < m; i++ {
        var u, v, x int
        scanner.NextInts(&u, &v, &x)
        AddEdge(grp[u], grp[v], x)
        if x == 0 {
            Union(u, v)
        }
    }
    if Check() {
        fmt.Println("Yes")
        SpfaAndPrint()
    } else {
        fmt.Println("No")
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInts(args ...*int) {
    for _, v := range args {
        *v = self.NextInt()
    }
}

type MyInt int

func (self MyInt) Min(x int) int {
    if int(self) < x {
        return int(self)
    }
    return x
}

/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-07 20:25]
*     Last Modified       :     [2014-03-07 22:26]
*     Description         :
**********************************************************************************/

package main

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

const inf = 0x3fffffff

var (
    n, m, k        int
    c, grp, parent []int
    g              [][]int
)

func AddEdge(a, b, c int) {
    g[a][b] = MyInt(g[a][b]).Min(c)
    g[b][a] = g[a][b]
}

func GetParent(x int) int {
    if x != parent[x] {
        parent[x] = GetParent(parent[x])
    }
    return parent[x]
}

func Union(a, b int) {
    pa, pb := GetParent(a), GetParent(b)
    if pa != pb {
        parent[pa] = pb
    }
}

func Check() bool {
    c[k] = n + 1
    for i := 0; i < k; i++ {
        p := GetParent(c[i])
        for j := c[i] + 1; j < c[i+1]; j++ {
            if p != GetParent(j) {
                return false
            }
        }
    }
    return true
}

func GetD() {
    for l := 0; l < k; l++ {
        for i := 0; i < k; i++ {
            if g[i][l] < inf {
                for j := 0; j < k; j++ {
                    g[i][j] = MyInt(g[i][j]).Min(g[i][l] + g[l][j])
                }
            }
        }
    }
    for i := 0; i < k; i++ {
        for j := 0; j < k; j++ {
            if j > 0 {
                fmt.Print(" ")
            }
            if g[i][j] >= inf {
                g[i][j] = -1
            }
            fmt.Print(g[i][j])
        }
        fmt.Println()
    }
}

func main() {
    scanner.Split(bufio.ScanWords)

    scanner.NextInts(&n, &m, &k)
    c, grp, parent = make([]int, k+1), make([]int, n+1), make([]int, n+1)
    g = make([][]int, k)
    for i, j := 0, 1; i < k; i++ {
        c[i], j = j, scanner.NextInt()+j
        for l := c[i]; l < j; l++ {
            grp[l], parent[l] = i, l
        }
        g[i] = make([]int, k)
        for l := 0; l < k; l++ {
            g[i][l] = inf
        }
        g[i][i] = 0
    }
    for i := 0; i < m; i++ {
        var u, v, x int
        scanner.NextInts(&u, &v, &x)
        AddEdge(grp[u], grp[v], x)
        if x == 0 {
            Union(u, v)
        }
    }
    if Check() {
        fmt.Println("Yes")
        GetD()
    } else {
        fmt.Println("No")
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInts(args ...*int) {
    for _, v := range args {
        *v = self.NextInt()
    }
}

type MyInt int

func (self MyInt) Min(x int) int {
    if int(self) < x {
        return int(self)
    }
    return x
}

package main

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

const maxn = 100010
const maxk = 510
const inf = 0x3fffffff

var p [maxn]int
var pnt [maxn]int
var g [maxk][maxk]int

func find(x int) int {
    if x == pnt[x] {
        return x
    } else {
        pnt[x] = find(pnt[x])
        return pnt[x]
    }
}
func main() {
    scanner.Split(bufio.ScanWords)
    n := scanner.NextInt()
    m := scanner.NextInt()
    k := scanner.NextInt()
    now := 1
    for i := 1; i <= k; i++ {
        for sz := scanner.NextInt(); sz > 0; sz-- {
            p[now] = i
            now++
        }
    }
    for i := 1; i <= n; i++ {
        pnt[i] = i
    }
    for i := 1; i <= k; i++ {
        for j := 1; j <= k; j++ {
            g[i][j] = inf
            if i == j {
                g[i][j] = 0
            }
        }
    }
    for i := 0; i < m; i++ {
        x := scanner.NextInt()
        y := scanner.NextInt()
        z := scanner.NextInt()
        if z == 0 {
            pnt[find(x)] = find(y)
        }
        if g[p[x]][p[y]] > z {
            g[p[x]][p[y]] = z
            g[p[y]][p[x]] = z
        }
    }
    ok := true
    for i := 2; ok && i <= n; i++ {
        ok = p[i] != p[i-1] || find(i) == find(i-1)
    }
    if !ok {
        fmt.Println("No")
    } else {
        fmt.Println("Yes")
        for i := 1; i <= k; i++ {
            for j := 1; j <= k; j++ {
                for v := 1; v <= k; v++ {
                    if g[j][v] > g[j][i]+g[i][v] {
                        g[j][v] = g[j][i] + g[i][v]
                    }
                }
            }
        }
        for i := 1; i <= k; i++ {
            for j := 1; j <= k; j++ {
                if g[i][j] == inf {
                    fmt.Printf("-1 ")
                } else {
                    fmt.Printf("%d ", g[i][j])
                }
            }
            fmt.Println()
        }
    }

}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}

/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-07 20:25]
*     Last Modified       :     [2014-03-07 22:26]
*     Description         :
**********************************************************************************/

package main

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

const inf = 0x3fffffff

var (
    n, m, k        int
    c, grp, parent []int
    g              [][]int
)

func AddEdge(a, b, c int) {
    g[a][b] = MyInt(g[a][b]).Min(c)
    g[b][a] = g[a][b]
}

func GetParent(x int) int {
    if x != parent[x] {
        parent[x] = GetParent(parent[x])
    }
    return parent[x]
}

func Union(a, b int) {
    pa, pb := GetParent(a), GetParent(b)
    if pa != pb {
        parent[pa] = pb
    }
}

func Check() bool {
    c[k] = n + 1
    for i := 0; i < k; i++ {
        p := GetParent(c[i])
        for j := c[i] + 1; j < c[i+1]; j++ {
            if p != GetParent(j) {
                return false
            }
        }
    }
    return true
}

func GetD() {
    for l := 0; l < k; l++ {
        for i := 0; i < k; i++ {
            if g[i][l] < inf {
                for j := 0; j < k; j++ {
                    g[i][j] = MyInt(g[i][j]).Min(g[i][l] + g[l][j])
                }
            }
        }
    }
    for i := 0; i < k; i++ {
        for j := 0; j < k; j++ {
            if j > 0 {
                fmt.Print(" ")
            }
            if g[i][j] >= inf {
                g[i][j] = -1
            }
            fmt.Print(g[i][j])
        }
        fmt.Println()
    }
}

func main() {
    scanner.Split(bufio.ScanWords)

    scanner.NextInts(&n, &m, &k)
    c, grp, parent = make([]int, k+1), make([]int, n+1), make([]int, n+1)
    g = make([][]int, k)
    for i, j := 0, 1; i < k; i++ {
        c[i], j = j, scanner.NextInt()+j
        for l := c[i]; l < j; l++ {
            grp[l], parent[l] = i, l
        }
        g[i] = make([]int, k)
        for l := 0; l < k; l++ {
            g[i][l] = inf
        }
        g[i][i] = 0
    }
    for i := 0; i < m; i++ {
        var u, v, x int
        scanner.NextInts(&u, &v, &x)
        AddEdge(grp[u], grp[v], x)
        if x == 0 {
            Union(u, v)
        }
    }
    if Check() {
        fmt.Println("Yes")
        GetD()
    } else {
        fmt.Println("No")
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) NextInt() int {
    x, _ := strconv.Atoi(self.Text())
    return x
}

func (self *Scanner) NextInts(args ...*int) {
    for _, v := range args {
        *v = self.NextInt()
    }
}

type MyInt int

func (self MyInt) Min(x int) int {
    if int(self) < x {
        return int(self)
    }
    return x
}

/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-06 21:27]
*     Last Modified       :     [2014-03-06 22:48]
*     Description         :
**********************************************************************************/

package main

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

const (
    N   = 100005
    K   = 505
    INF = 0x3fffffff
)

type Pair struct {
    v, x int
}

var n, m, k, u, v, x int
var c [K]int
var d [K][K]int
var g [N][]Pair

func SpfaAndTest(kind, idx int) bool {
    var (
        q   = make(chan int, n)
        dst = make([]int, n+1)
        inq = make([]bool, n+1)
    )
    for i := 1; i <= n; i++ {
        dst[i], inq[i] = INF, false
    }
    for i, j := range c[:kind] {
        for k := j; k < c[i+1]; k++ {
            dst[k] = d[i][kind]
        }
    }
    q <- idx
    dst[idx] = 0
    inq[idx] = true
    for len(q) > 0 {
        f := <-q
        inq[f] = false
        for _, p := range g[f] {
            if dst[p.v] > dst[f]+p.x {
                dst[p.v] = dst[f] + p.x
                if !inq[p.v] {
                    q <- p.v
                    inq[p.v] = true
                }
            }
        }
    }
    //fmt.Println(kind, idx, dst)
    tmp := n + 1
    if kind < k-1 {
        tmp = c[kind+1]
    }
    for i := idx; i < tmp; i++ {
        if dst[i] > 0 {
            return false
        }
    }
    for i, j := range c[:k] {
        d[kind][i], d[i][kind] = dst[j], dst[j]
    }
    return true
}

func solve() bool {
    for i, v := range c[:k] {
        if SpfaAndTest(i, v) == false {
            return false
        }
    }
    return true
}

func main() {
    scanner.Split(bufio.ScanWords)

    scanner.nextInts(&n, &m, &k)
    for i := 1; i <= n; i++ {
        g[i] = make([]Pair, 0)
    }
    for i, j := 0, 1; i < k; i++ {
        j, c[i] = scanner.nextInt()+j, j
    }
    for i := 0; i < m; i++ {
        scanner.nextInts(&u, &v, &x)
        g[u] = append(g[u], Pair{v, x})
        g[v] = append(g[v], Pair{u, x})
    }
    if solve() {
        fmt.Println("Yes")
        for i := 0; i < k; i++ {
            for j := 0; j < k; j++ {
                if j != 0 {
                    fmt.Print(" ")
                }
                if d[i][j] >= INF {
                    d[i][j] = -1
                }
                fmt.Print(d[i][j])
            }
            fmt.Println()
        }
    } else {
        fmt.Println("No")
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) nextInt() int {
    x, err := strconv.Atoi(self.next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) nextInts(arg ...*int) {
    for _, p := range arg {
        *p = self.nextInt()
    }
}

/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-07 20:25]
*     Last Modified       :     [2014-03-07 22:26]
*     Description         :
**********************************************************************************/

package main

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

const inf = 0x3fffffff

var (
    n, m, k        int
    c, grp, parent []int
    g              [][]int
)

func AddEdge(a, b, c int) {
    g[a][b] = MyInt(g[a][b]).Min(c)
    g[b][a] = g[a][b]
}

func GetParent(x int) int {
    if x != parent[x] {
        parent[x] = GetParent(parent[x])
    }
    return parent[x]
}

func Union(a, b int) {
    pa, pb := GetParent(a), GetParent(b)
    if pa != pb {
        parent[pa] = pb
    }
}

func Check() bool {
    c[k] = n + 1
    for i := 0; i < k; i++ {
        p := GetParent(c[i])
        for j := c[i] + 1; j < c[i+1]; j++ {
            if p != GetParent(j) {
                return false
            }
        }
    }
    return true
}

func GetD() {
    for l := 0; l < k; l++ {
        for i := 0; i < k; i++ {
            if g[i][l] < inf {
                for j := 0; j < k; j++ {
                    g[i][j] = MyInt(g[i][j]).Min(g[i][l] + g[l][j])
                }
            }
        }
    }
    for i := 0; i < k; i++ {
        for j := 0; j < k; j++ {
            if j > 0 {
                fmt.Print(" ")
            }
            if g[i][j] >= inf {
                g[i][j] = -1
            }
            fmt.Print(g[i][j])
        }
        fmt.Println()
    }
}

func main() {
    scanner.Split(bufio.ScanWords)

    scanner.NextInts(&n, &m, &k)
    c, grp, parent = make([]int, k+1), make([]int, n+1), make([]int, n+1)
    g = make([][]int, k)
    for i, j := 0, 1; i < k; i++ {
        c[i], j = j, scanner.NextInt()+j
        for l := c[i]; l < j; l++ {
            grp[l], parent[l] = i, l
        }
        g[i] = make([]int, k)
        for l := 0; l < k; l++ {
            g[i][l] = inf
        }
        g[i][i] = 0
    }
    for i := 0; i < m; i++ {
        var u, v, x int
        scanner.NextInts(&u, &v, &x)
        AddEdge(grp[u], grp[v], x)
        if x == 0 {
            Union(u, v)
        }
    }
    if Check() {
        fmt.Println("Yes")
        GetD()
    } else {
        fmt.Println("No")
    }
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, _ := strconv.Atoi(self.Text())
    return x
}

func (self *Scanner) NextInts(args ...*int) {
    for _, v := range args {
        *v = self.NextInt()
    }
}

type MyInt int

func (self MyInt) Min(x int) int {
    if int(self) < x {
        return int(self)
    }
    return x
}

package main

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

const maxn = 100010
const maxk = 510
const inf = 0x3fffffff

var p [maxn]int
var pnt [maxn]int
var g [maxk][maxk]int

func find(x int) int {
    if x == pnt[x] {
        return x
    } else {
        pnt[x] = find(pnt[x])
        return pnt[x]
    }
}
func main() {
    scanner.Split(bufio.ScanWords)
    n := scanner.NextInt()
    m := scanner.NextInt()
    k := scanner.NextInt()
    now := 1
    for i := 1; i <= k; i++ {
        for sz := scanner.NextInt(); sz > 0; sz-- {
            p[now] = i
            now++
        }
    }
    for i := 1; i <= n; i++ {
        pnt[i] = i
    }
    for i := 1; i <= k; i++ {
        for j := 1; j <= k; j++ {
            g[i][j] = inf
            if i == j {
                g[i][j] = 0
            }
        }
    }
    for i := 0; i < m; i++ {
        x := scanner.NextInt()
        y := scanner.NextInt()
        z := scanner.NextInt()
        pnt[find(x)] = find(y)
        if g[p[x]][p[y]] > z {
            g[p[x]][p[y]] = z
            g[p[y]][p[x]] = z
        }
    }
    ok := true
    for i := 2; ok && i <= n; i++ {
        ok = p[i] != p[i-1] || find(i) == find(i-1)
    }
    if !ok {
        fmt.Println("No")
    } else {
        fmt.Println("Yes")
        for i := 1; i <= k; i++ {
            for j := 1; j <= k; j++ {
                for v := 1; v <= k; v++ {
                    if g[j][v] > g[j][i]+g[i][v] {
                        g[j][v] = g[j][i] + g[i][v]
                    }
                }
            }
        }
        for i := 1; i <= k; i++ {
            for j := 1; j <= k; j++ {
                if g[i][j] == inf {
                    fmt.Printf("-1 ")
                } else {
                    fmt.Printf("%d ", g[i][j])
                }
            }
            fmt.Println()
        }
    }

}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}

package main

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

const maxn = 100010
const maxk = 510
const inf = 0x3fffffff

var p [maxn]int
var pnt [maxn]int
var g [maxk][maxk]int

func find(x int) int {
    if x == pnt[x] {
        return x
    } else {
        pnt[x] = find(pnt[x])
        return pnt[x]
    }
}
func main() {
    scanner.Split(bufio.ScanWords)
    n := scanner.NextInt()
    m := scanner.NextInt()
    k := scanner.NextInt()
    now := 1
    for i := 1; i <= k; i++ {
        for sz := scanner.NextInt(); sz > 0; sz-- {
            p[now] = i
            now++
        }
    }
    for i := 1; i <= n; i++ {
        pnt[i] = i
    }
    for i := 1; i <= k; i++ {
        for j := 1; j <= k; j++ {
            g[i][j] = inf
            if i == j {
                g[i][j] = 0
            }
        }
    }
    for i := 0; i < m; i++ {
        x := scanner.NextInt()
        y := scanner.NextInt()
        z := scanner.NextInt()
        if z == 0 && p[x] == p[y] {
            pnt[find(x)] = find(y)
        }
        if g[p[x]][p[y]] > z {
            g[p[x]][p[y]] = z
            g[p[y]][p[x]] = z
        }
    }
    ok := true
    for i := 2; ok && i <= n; i++ {
        ok = p[i] != p[i-1] || find(i) == find(i-1)
    }
    if !ok {
        fmt.Println("No")
    } else {
        fmt.Println("Yes")
        for i := 1; i <= k; i++ {
            for j := 1; j <= k; j++ {
                for v := 1; v <= k; v++ {
                    if g[j][v] > g[j][i]+g[i][v] {
                        g[j][v] = g[j][i] + g[i][v]
                    }
                }
            }
        }
        for i := 1; i <= k; i++ {
            for j := 1; j <= k; j++ {
                if g[i][j] == inf {
                    fmt.Printf("-1 ")
                } else {
                    fmt.Printf("%d ", g[i][j])
                }
            }
            fmt.Println()
        }
    }

}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}


package main

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

// Input & Output
var (
	input  = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

var (
	n      int
	m      int
	a      []int64
	b      []int64
	ra, rb int
)

type ByValue []int64

func (v ByValue) Len() int {
	return len(v)
}

func (v ByValue) Swap(i, j int) {
	v[i], v[j] = v[j], v[i]
}

func (v ByValue) Less(i, j int) bool {
	return v[i] < v[j]
}

func in() {
	fmt.Fscan(input, &n)
	a = make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(input, &a[i])
	}
	fmt.Fscan(input, &m)
	b = make([]int64, m)
	for i := 0; i < m; i++ {
		fmt.Fscan(input, &b[i])
	}
}

func out() {
	fmt.Fprintf(output, "%d:%d\n", ra, rb)
	defer output.Flush()
}

func run() {
	sort.Sort(ByValue(a))
	sort.Sort(ByValue(b))
	sa := make([]int, m+1)
	sb := make([]int, m+1)
	sa[0] = 3 * n
	sb[0] = 3 * m
	pa, pb := 0, 0
	for ; pb < m; pb++ {
		if pb < m-1 && b[pb+1] == b[pb] {
			pb++
		}
		for pa < n && a[pa] <= b[pb] {
			pa++
		}
		sa[pb+1] = 2*pa + 3*(n-pa)
		sb[pb+1] = 2*(pb+1) + 3*(m-pb-1)
	}
	var adv int = math.MinInt32
	for i := 0; i < len(sa); i++ {
		if sa[i] > 0 && sa[i]-sb[i] > adv {
			adv = sa[i] - sb[i]
			ra = sa[i]
			rb = sb[i]
		}
	}
}

func main() {
	in()
	run()
	out()
}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func getData(scanner *bufio.Scanner) ([]int, map[int]int) {
	n := scanInt(scanner)
	throws := make([]int, n)
	for i := range throws {
		throws[i] = scanInt(scanner)
	}
  sort.Ints(throws)
  unique_throws, counts := []int{}, map[int]int{}
  count, previous := 0, 0
  for i, throw := range throws {
    if throw == previous {
      count += 1
    } else {
      unique_throws = append(unique_throws, previous)
      counts[previous] = i
      count, previous = 1, throw
    }
  }
  unique_throws = append(unique_throws, throws[n-1])
  counts[throws[n-1]] = n
  return unique_throws, counts
}

func calculateScore(d int, unique_throws []int, counts map[int]int) int {
  low, high := 0, len(unique_throws)-1
  for low != high {
    mid := (low+high+1)/2
    if d < unique_throws[mid] {
      high = mid-1
    } else {
      low = mid
    }
  }
  twos := counts[unique_throws[low]]
  threes := counts[unique_throws[len(unique_throws)-1]] - twos
  score := 2*twos + 3*threes
  return score
}

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

  n_unique_throws, n_counts := getData(scanner)
  m_unique_throws, m_counts := getData(scanner)
  ds := []int{}
  for _, x := range n_unique_throws {
    ds = append(ds, x-1)
  }
  for _, x := range m_unique_throws {
    ds = append(ds, x-1)
  }
  n, m := len(n_unique_throws), len(m_unique_throws)
  ds = append(ds, n_unique_throws[n-1])
  ds = append(ds, m_unique_throws[m-1])

  best_a := calculateScore(0, n_unique_throws, n_counts)
  best_b := calculateScore(0, m_unique_throws, m_counts)
  for _, d := range ds {
    a := calculateScore(d, n_unique_throws, n_counts)
    b := calculateScore(d, m_unique_throws, m_counts)
    if a-b > best_a-best_b || (a-b == best_a-best_b && a > best_a) {
      best_a = a
      best_b = b
    }
  }

  writer.WriteString(fmt.Sprintf("%d:%d\n", best_a, best_b))
}

package main

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

func main() {
    n, m := 0, 0
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)

    ScanInts := func(a ...*int) {
        for i := 0; i < len(a); i++ {
            scanner.Scan()
            *(a[i]), _ = strconv.Atoi(scanner.Text())
        }
    }
    ScanInts(&n)
    fir := make([]int, n, n)
    for i := 0; i < n; i++ {
        ScanInts(&fir[i])
    }
    ScanInts(&m)
    sec := make([]int, m, m)
    for i := 0; i < m; i++ {
        ScanInts(&sec[i])
    }
    sort.Ints(fir)
    sort.Ints(sec)
    ans, a, b := 0, 0, 0
    if n*2-m*2 > n*3-m*3 {
        a, b = n*2, m*2
    } else {
        a, b = n*3, m*3
    }
    ans = a - b
    for i := 0; i < n; i++ {
        key := fir[i] - 1
        idx := lower_bound(0, m-1, key, sec)
        s, f := 0, i*2+(n-i)*3
        if sec[idx] > key {
            s = idx*2 + (m-idx)*3
        } else if sec[idx] == key {
            idx := lower_bound(0, m-1, key+1, sec)
            if sec[idx] <= key {
                s = m * 2
            } else {
                s = idx*2 + (m-idx)*3
            }
        } else {
            s = m * 2
        }
        if f-s > ans || (f-s == ans && f > a) {
            a, b = f, s
            ans = f - s
        }
    }
    fmt.Printf("%d:%d", a, b)
}

func lower_bound(l, r, key int, arr []int) int {
    for l < r {
        mid := (l + r) >> 1
        if arr[mid] < key {
            l = mid + 1
        } else {
            r = mid
        }
    }
    return l
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	sort.Ints(a)
	sort.Ints(b)
	c := append(a, b...)
	c = append(c, 1<<30)
	sort.Ints(c)
	var ma, mb int
	mb = 1 << 30
	for i, j, k := 0, 0, 0; k <= n+m; k++ {
		th := c[k] - 1
		for i < n && a[i] <= th {
			i++
		}
		for j < m && b[j] <= th {
			j++
		}
		pa := 2*i + 3*(n-i)
		pb := 2*j + 3*(m-j)
		if pa-pb > ma-mb {
			ma, mb = pa, pb
		}
	}
	fmt.Printf("%d:%d\n", ma, mb)
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
    "sort"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func getPoints(a []int, d int) int {
    l := 0
    r := len(a) - 1
    for l < r {
        m := l + (r - l) / 2
        if a[m] <= d {
            l = m + 1
        } else {
            r = m
        }
    }
    // fmt.Fprintln(out, d)
    // fmt.Fprintln(out, l)
    // fmt.Fprintln(out, a)
    if a[r] > d { r-- }
    return (r + 1) * 2 + (len(a) - r - 1) * 3
}

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }
    m := nextInt()
    b := make([]int, m)
    for i := 0; i < m; i++ {
        b[i] = nextInt()
    }

    sort.Ints(a)
    sort.Ints(b)
    c := append(a, b...)
    c = append(c, 0)
    c = append(c, 2000000001)
    sort.Ints(c)
    aa := 0
    ab := 0
    max := -2000000001
    for i := 0; i < len(c); i++ {
        d := c[i]
        pa := getPoints(a, d)
        pb := getPoints(b, d)
        if max < pa - pb {
            max = pa - pb
            aa = pa
            ab = pb
        }
    }

    fmt.Fprintln(out, strconv.Itoa(aa) + ":" + strconv.Itoa(ab))
}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func getData(scanner *bufio.Scanner) ([]int, map[int]int) {
	n := scanInt(scanner)
	throws := make([]int, n)
	for i := range throws {
		throws[i] = scanInt(scanner)
	}
  sort.Ints(throws)
  unique_throws, counts := []int{}, map[int]int{}
  count, previous := 0, 0
  for i, throw := range throws {
    if throw == previous {
      count += 1
    } else {
      unique_throws = append(unique_throws, previous)
      counts[previous] = i
      count, previous = 1, throw
    }
  }
  unique_throws = append(unique_throws, throws[n-1])
  counts[throws[n-1]] = n
  return unique_throws, counts
}

func calculateScore(d int, unique_throws []int, counts map[int]int) int {
  low, high := 0, len(unique_throws)-1
  for low != high {
    //fmt.Printf("%d %d\n", low, high)
    mid := (low+high+1)/2
    if d < unique_throws[mid] {
      high = mid-1
    } else {
      low = mid
    }
  }
  twos := counts[low]
  threes := counts[unique_throws[len(unique_throws)-1]] - twos
  score := 2*twos + 3*threes
  //fmt.Printf("d = %d, low = %d, score = %d\n", d, low, score)
  return score
}

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

  n_unique_throws, n_counts := getData(scanner)
  m_unique_throws, m_counts := getData(scanner)
  ds := []int{}
  for _, x := range n_unique_throws {
    ds = append(ds, x-1)
  }
  for _, x := range m_unique_throws {
    ds = append(ds, x-1)
  }
  n, m := len(n_unique_throws), len(m_unique_throws)
  ds = append(ds, n_unique_throws[n-1])
  ds = append(ds, m_unique_throws[m-1])

  best_a := calculateScore(0, n_unique_throws, n_counts)
  best_b := calculateScore(0, m_unique_throws, m_counts)
  for _, d := range ds {
    a := calculateScore(d, n_unique_throws, n_counts)
    b := calculateScore(d, m_unique_throws, m_counts)
    if a-b > best_a-best_b || (a-b == best_a-best_b && a > best_a) {
      best_a = a
      best_b = b
    }
  }

  writer.WriteString(fmt.Sprintf("%d:%d\n", best_a, best_b))
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	var maxD, ma, mb int64
	for i, j := 0, 0; i < n; i++ {
		th := a[i] - 1
		for j < m && b[j] <= th {
			j++
		}
		pa := int64(2*i + 3*(n-i))
		pb := int64(2*j + 3*(m-j))
		if pa-pb > maxD {
			maxD = pa - pb
			ma, mb = pa, pb
		}
	}
	fmt.Printf("%d:%d\n", ma, mb)
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	var maxD, ma, mb int
	maxD = -1
	for i, j := 0, 0; i < n; i++ {
		th := a[i] - 1
		for j < m && b[j] <= th {
			j++
		}
		pa := 2*i + 3*(n-i)
		pb := 2*j + 3*(m-j)
		if pa-pb > maxD {
			maxD = pa - pb
			ma, mb = pa, pb
		}
	}
	fmt.Printf("%d:%d\n", ma, mb)
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	var maxD, ma, mb int
	maxD = -(1 << 30)
	for i, j := 0, 0; i < n; i++ {
		th := a[i] - 1
		for j < m && b[j] <= th {
			j++
		}
		pa := 2*i + 3*(n-i)
		pb := 2*j + 3*(m-j)
		if pa-pb > maxD {
			maxD = pa - pb
			ma, mb = pa, pb
		}
	}
	fmt.Printf("%d:%d\n", ma, mb)
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	sort.Ints(a)
	sort.Ints(b)
	var maxD, ma, mb int
	maxD = -(1 << 30)
	for i, j := 0, 0; i < n; i++ {
		th := a[i] - 1
		for j < m && b[j] <= th {
			j++
		}
		pa := 2*i + 3*(n-i)
		pb := 2*j + 3*(m-j)
		if pa-pb > maxD {
			maxD = pa - pb
			ma, mb = pa, pb
		}
	}
	fmt.Printf("%d:%d\n", ma, mb)
}

package main

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

// import bufio, os, strconv
var sc *bufio.Scanner

func scInit() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
}

func scanOne() {
	if !sc.Scan() {
		panic("could not scan the reader")
	}
}

func nextInt() int {
	scanOne()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLong() int64 {
	scanOne()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func next() string {
	scanOne()
	return sc.Text()
}

func main() {
	scInit()
	n := nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	m := nextInt()
	b := make([]int, m)
	for i := 0; i < m; i++ {
		b[i] = nextInt()
	}
	sort.Ints(a)
	sort.Ints(b)
	ma := 3 * n
	mb := 3 * m
	maxD := ma - mb
	for i, j := 0, 0; i < n; i++ {
		th := a[i] - 1
		for j < m && b[j] <= th {
			j++
		}
		pa := 2*i + 3*(n-i)
		pb := 2*j + 3*(m-j)
		if pa-pb > maxD {
			maxD = pa - pb
			ma, mb = pa, pb
		}
	}
	fmt.Printf("%d:%d\n", ma, mb)
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
    "sort"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func getPoints(a []int, d int) int {
    l := 0
    r := len(a) - 1
    for l < r {
        m := l + (r - l) / 2
        if a[m] <= d {
            l = m + 1
        } else {
            r = m
        }
    }
    // fmt.Fprintln(out, d)
    // fmt.Fprintln(out, l)
    // fmt.Fprintln(out, a)
    if a[r] > d { r-- }
    return (r + 1) * 2 + (len(a) - r - 1) * 3
}

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }
    m := nextInt()
    b := make([]int, m)
    for i := 0; i < m; i++ {
        b[i] = nextInt()
    }

    sort.Ints(a)
    sort.Ints(b)
    c := append(a, b...)
    c = append(c, 0)
    c = append(c, 2000000001)
    sort.Ints(c)
    aa := 0
    ab := 0
    max := 0
    for i := 0; i < len(c); i++ {
        d := c[i]
        pa := getPoints(a, d)
        pb := getPoints(b, d)
        if max < abs(pa - pb) {
            max = abs(pa - pb)
            aa = pa
            ab = pb
        }
    }

    fmt.Fprintln(out, strconv.Itoa(aa) + ":" + strconv.Itoa(ab))
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
    "sort"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func getPoints(a []int, d int) int {
    l := 0
    r := len(a) - 1
    for l < r {
        m := l + (r - l) / 2
        if a[m] <= d {
            l = m + 1
        } else {
            r = m
        }
    }
    // fmt.Fprintln(out, d)
    // fmt.Fprintln(out, l)
    // fmt.Fprintln(out, a)
    if a[r] > d { r-- }
    return (r + 1) * 2 + (len(a) - r - 1) * 3
}

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }
    m := nextInt()
    b := make([]int, m)
    for i := 0; i < m; i++ {
        b[i] = nextInt()
    }

    sort.Ints(a)
    sort.Ints(b)
    d := a[0] - 1
    pa := len(a) * 3
    pb := getPoints(b, d)
    aa := pa
    ab := pb
    max := pa - pb
    for i := 0; i < n; i++ {
        d := a[i]
        pa := (i + 1) * 2 + (len(a) - i - 1) * 3
        pb := getPoints(b, d)
        if max < pa - pb {
            max = pa - pb
            aa = pa
            ab = pb
        }
    }

    fmt.Fprintln(out, strconv.Itoa(aa) + ":" + strconv.Itoa(ab))
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
    "sort"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func getPoints(a []int, d int) int {
    l := 0
    r := len(a) - 1
    for l < r {
        m := l + (r - l) / 2
        if a[m] <= d {
            l = m + 1
        } else {
            r = m
        }
    }
    // fmt.Fprintln(out, d)
    // fmt.Fprintln(out, l)
    // fmt.Fprintln(out, a)
    if a[r] > d { r-- }
    return (r + 1) * 2 + (len(a) - r - 1) * 3
}

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }
    m := nextInt()
    b := make([]int, m)
    for i := 0; i < m; i++ {
        b[i] = nextInt()
    }

    sort.Ints(a)
    sort.Ints(b)
    d := a[0] - 1
    pa := len(a) * 3
    pb := getPoints(b, d)
    aa := pa
    ab := pb
    max := abs(pa - pb)
    for i := 0; i < n; i++ {
        d := a[i]
        pa := (i + 1) * 2 + (len(a) - i - 1) * 3
        pb := getPoints(b, d)
        if max < abs(pa - pb) {
            max = abs(pa - pb)
            aa = pa
            ab = pb
        }
    }

    fmt.Fprintln(out, strconv.Itoa(aa) + ":" + strconv.Itoa(ab))
}