An IPv6-address is a 128-bit number. For convenience, this number is recorded in blocks of 16 bits in hexadecimal record, the blocks are separated by colons — 8 blocks in total, each block has four hexadecimal digits. Here is an example of the correct record of a IPv6 address: "0124:5678:90ab:cdef:0124:5678:90ab:cdef". We'll call such format of recording an IPv6-address full.

Besides the full record of an IPv6 address there is a short record format. The record of an IPv6 address can be shortened by removing one or more leading zeroes at the beginning of each block. However, each block should contain at least one digit in the short format. For example, the leading zeroes can be removed like that: "a56f:00d3:0000:0124:0001:f19a:1000:0000"  →  "a56f:d3:0:0124:01:f19a:1000:00". There are more ways to shorten zeroes in this IPv6 address.

Some IPv6 addresses contain long sequences of zeroes. Continuous sequences of 16-bit zero blocks can be shortened to "::". A sequence can consist of one or several consecutive blocks, with all 16 bits equal to 0. 

You can see examples of zero block shortenings below:

  "a56f:00d3:0000:0124:0001:0000:0000:0000"  →  "a56f:00d3:0000:0124:0001::";  "a56f:0000:0000:0124:0001:0000:1234:0ff0"  →  "a56f::0124:0001:0000:1234:0ff0";  "a56f:0000:0000:0000:0001:0000:1234:0ff0"  →  "a56f:0000::0000:0001:0000:1234:0ff0";  "a56f:00d3:0000:0124:0001:0000:0000:0000"  →  "a56f:00d3:0000:0124:0001::0000";  "0000:0000:0000:0000:0000:0000:0000:0000"  →  "::". 

It is not allowed to shorten zero blocks in the address more than once. This means that the short record can't contain the sequence of characters "::" more than once. Otherwise, it will sometimes be impossible to determine the number of zero blocks, each represented by a double colon.

The format of the record of the IPv6 address after removing the leading zeroes and shortening the zero blocks is called short.

You've got several short records of IPv6 addresses. Restore their full record.


-----Input-----

The first line contains a single integer n — the number of records to restore (1 ≤ n ≤ 100).

Each of the following n lines contains a string — the short IPv6 addresses. Each string only consists of string characters "0123456789abcdef:".

It is guaranteed that each short address is obtained by the way that is described in the statement from some full IPv6 address.


-----Output-----

For each short IPv6 address from the input print its full record on a separate line. Print the full records for the short IPv6 addresses in the order, in which the short records follow in the input.


-----Examples-----
Input
6
a56f:d3:0:0124:01:f19a:1000:00
a56f:00d3:0000:0124:0001::
a56f::0124:0001:0000:1234:0ff0
a56f:0000::0000:0001:0000:1234:0ff0
::
0ea::4d:f4:6:0

Output
a56f:00d3:0000:0124:0001:f19a:1000:0000
a56f:00d3:0000:0124:0001:0000:0000:0000
a56f:0000:0000:0124:0001:0000:1234:0ff0
a56f:0000:0000:0000:0001:0000:1234:0ff0
0000:0000:0000:0000:0000:0000:0000:0000
00ea:0000:0000:0000:004d:00f4:0006:0000

Difficulty: interview

Starter code:

Solutions:
for i in range(int(input())):
    t = input().split(':')
    if t[-1] == '': t.pop()
    elif t[0] == '': t.pop(0)
    if '' in t: t[t.index('')] = ('0000:' * (9 - len(t)))[: -1]
    print(':'.join('0' * (4 - len(i)) + i for i in t))

for i in range(int(input())):
    t = input().split(':')
    if '' in t:
        j = t.index('')
        t[j: j + 1] = [''] * (9 - len(t))
    print(':'.join(j.rjust(4, '0') for j in t))

n = int(input())
short_ips = []
for i in range(n):
    short_ips.append(input())


# leading zeros can be deleted, but has to have one number remained
# Continuous sequences of 16-bit zero blocks can be shortened to "::"


answers = [[]  for x in range(n)]
ans_id = -1
for ip in short_ips:
    ans_id += 1
    visited = False
    segments = ip.split(':')
    for segment in segments:
        if len(segment) == 0:
            if visited:
                answers[ans_id].append("0"*4)
                continue
            visited = True
            missing = 8 - len(segments)
            for i in range(missing+1):
                answers[ans_id].append("0"*4)
        elif len(segment) == 4:
            answers[ans_id].append(segment)
        else:
            leading = 4 - len(segment)
            answers[ans_id].append("0" *leading + segment)

for restored in answers:
    print(':'.join(restored))

n = int(input())

adrs = [input().split(':') for i in range(n)]

res = []

for ad in adrs:
    new_ad = ''
    ind = 0
    for s in ad:
        if s:
            new_ad += '0'*(4-len(s)) + s + ' '
        elif s == '::':
            res.append('0000 ' * 8)
            break
        elif not s and ind == 0:
            new_ad += '0000 '*(8-len(ad)+ad.count(''))
            ind = 1
    res.append(new_ad)

    
for x in res:
    print(x.replace(' ', ':')[:39])

n = int(input())
for i in range(n):
	r = input().split(':')
	s = ':'.join(x.zfill(4) if x else x for x in r)
	while len(s) < 39:
		x = s.index('::')
		s = s[:x + 1] + '0000:' + s[x + 1:]
	if '::' in s:
		x = s.index('::')
		s = s[:x + 1] + s[x + 2:]
	print(s.strip(':'))


import sys

def solve():
    n = int(input())
    for test in range(n):
        line = input().split(':')
        i = 0
        while i < len(line):
            if i > 0 and line[i] == '' and line[i-1] == '':
                line.pop(i)
                i-=1
            i+=1
        for i, string in enumerate(line):
            if string == '': line[i] = modify(string, want = (32 - 4 * (len(line) - 1)))
            else: line[i] = modify(string)
        tempstr = ''.join(line)
        chunked = [tempstr[i: i + 4] for i in range(0, 32, 4)]
        print(':'.join(chunked))

def modify(string, want = 4):
    while len(string) < want:
        string='0' + string
    return string
        # print(line)
        # res = ""
        # otherblocks = 0
        # sawprev = False
        # for c in line:
        #     if c != ':' and sawprev == False:
        #         otherblocks+=1
        #         sawprev = True
        #     if c == ':':
        #         sawprev = False
        # print(otherblocks)


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

def f(s):
    res = []
    sp = s.split(":")
    if not sp[0]:
        sp[0] = "0"
    if not sp[-1]:
        sp[-1] = "0"
    for b in sp:
        if b:
            res.append("{:0>4}".format(b))
        if not b:
            res.extend(("0000" for i in range(8-len(sp)+1)))
    return(":".join(res))

for i in range(int(input())):
    tmp = input()
    print(f(tmp))

#print(check("R23C55"))
#print(check("R228C494"))
#print(f("::"))


count=input()
#count=5
for i in range(int(count)):
    n=input()
    #n='::a:6:c50:83:4f:7f0d:9'
    ip=n.split(':')
    #print(ip)
    begin=0
    end=0
    if (ip[0]=='' and ip[1]=='' and len(ip)>8):
        begin=1
    if (ip[len(ip)-2]=='' and ip[len(ip)-1]==''  and len(ip)>8):
        end=1
    while len(ip)<8:
        index=ip.index('')
        ip=ip[:index]+['']+ip[index:]
    #print(ip)
    for item in ip:
        i=item
        while len(i)<4:
            i='0'+i
        ip[ip.index(item)]=i
    if end==1:
        ip=ip[:len(ip)-1]
    if begin==1:
        ip=ip[1:]
    print(':'.join(ip))




import re

n = int(input())
for i in range(n):
    s = input().strip()
    group_count = s.count(':') + 1
    if group_count < 8:
        s = re.sub('::', ':' + (9 - group_count) * '0000:', s)
    elif group_count == 9:
        s = re.sub('::', ':', s)
    groups = s.split(':')
    for i, group in enumerate(groups):
        if len(group) < 4:
            groups[i] = (4 - len(group)) * '0' + group
    print(':'.join(groups))


import re

n = int(input())
for i in range(n):
    s = input().strip()
    group_count = s.count(':') + 1
    s = re.sub('::', ':' + (9 - group_count) * '0000:', s)
    groups = s.split(':')
    for i, group in enumerate(groups):
        if len(group) < 4:
            groups[i] = (4 - len(group)) * '0' + group
    print(':'.join(groups))


n = int(input())
list=[]
for i in range(n):
    str=input()
    list=str.split(":")
    if(str.count("::")>0):
        t=list.count("")
        if(t==3):
            t="0000:"*8
            print(t[:len(t)-1])
        elif t==2:
            if str[0:2]=='::':

                str=str.replace("::","0000:"*(10-len(list)))
                res=""
                list2=str.split(":")
                for i in range(len(list2)):
                    res+='0'*(4-len(list2[i]))+list2[i]+":"
                print(res[0:len(res)-1])
                #print(str)

            else:
                str=str.replace("::",":0000"*(10-len(list)))
                res=""
                list2=str.split(":")
                for i in range(len(list2)):
                    res+='0'*(4-len(list2[i]))+list2[i]+":"
                print(res[0:len(res)-1])
                #print(str)
        else:
            str=str.replace("::",":0000:"*(9-len(list)))
            str=str.replace("::",":");
            res=""
            list2=str.split(":")
            for i in range(len(list2)):
                res+='0'*(4-len(list2[i]))+list2[i]+":"
            print(res[0:len(res)-1])
          #  print(str)



    else:
        res=""
        for i in range(len(list)):
            res+='0'*(4-len(list[i]))+list[i]+":"
        print(res[0:len(res)-1])


def s():
	n = int(input())
	def st(x):
		if x[0] == ':':
			x = x[1:]
		if x[-1] == ':':
			x = x[:-1]
		return x
	for _ in range(n):
		a = st(input()).split(':')
		for i in range(len(a)):
			if len(a[i]) == 0:
				a[i] = '0000:'*(8-len(a))+'0000'
			elif len(a[i])<4:
				a[i] = '0'*(4-len(a[i]))+a[i]
		print(*a,sep=':')
s()

n = int(input())
ips = [input() for j in range(n)]

for ip in ips:
    if ip.find("::") != -1:
        ip = ip.replace("::", ":" * (9 - ip.count(":")))
    comps = ip.split(":")
    for i in range(len(comps)):
        comps[i] = "0" * (4 - len(comps[i])) + comps[i]
    print(":".join(comps))

for i in range(int(input())):
  ipv6 = input().split(':')
  ipv6 = [((4 - len(i))*'0' + i) if i != '' else '' for i in ipv6]
  if ipv6[-1] == '':
    ipv6[-1] = '0000'
  if ipv6[0] == '':
    ipv6[0] = '0000'
  if '' in ipv6:
    string = '0000:'*(8 - len(ipv6) + 1)
    ipv6[ipv6.index('')] = string[:-1]
  if '' in ipv6:
    ipv6.remove('')
  print(':'.join(ipv6))

import re
n=int(input())
for i in range(n):
	s=input().strip()
	group_count=s.count(':')+1
	s=re.sub('::',':'+(9-group_count)*'0000:',s)
	groups=s.split(':')
	for i,group in enumerate(groups):
		if len(group)<4:
			groups[i]=(4-len(group))*'0'+group
	print(':'.join(groups))




def restora(lin):
    lin = lin.split(":")
    ans = []
    falt = 8
    for w in lin:
        if w != "":
            falt -= 1
    for w in lin:
        if w == "":
            while falt > 0:
                ans.append("0000")
                falt -= 1
            continue
        while len(w) < 4:
            w = '0' + w
        ans.append(w)
    return ':'.join(ans)


def main():
    n = int(input())
    for i in range(n):
        print(restora(input()))


main()



def index(lena):
    if lena==8:
        return 4
    elif lena==7:
        return 9
    elif lena==6:
        return 14
    elif lena==5:
        return 19
    elif lena==4:
        return 24
    elif lena==3:
        return 29
    elif lena==2:
        return 34
    elif lena==1:
        return 39
    
   
            
        


s = int(input())

ip = []
for a in range(s):
    q = input().split(':')
    q1 = []
    c=0
    for a in q:
        if a=='' and c==0:
            q1.append(a)
            c = 1
        elif a=='' and c==1:
            pass
        
        else:
            q1.append(a)
        

    ip.append(q1)
    
    

for a in ip:
    s = []
    lena = len(a)
    z = '0000:0000:0000:0000:0000:0000:0000:0000'
    for i in range(lena):
        if a[i]=='':   
            s.append(z[:index(lena)])
        else:    
            q = "{0:0>4}".format(a[i])
            s.append(q)
    res = ':'.join(s)
    print(res)

for i in range(int(input())):

    t = input().split(':')

    if t[-1] == '': t.pop()

    elif t[0] == '': t.pop(0)

    if '' in t: t[t.index('')] = ('0000:' * (9 - len(t)))[: -1]

    print(':'.join('0' * (4 - len(i)) + i for i in t))



# Made By Mostafa_Khaled


def zr(s):
	tmp=':0000'
	if s=='::':
		return tmp[1:]+7*tmp
	ind=s.find("::")
	if ind<0:
		return s
	h,k=1,0
	if ind==0 or ind==len(s)-2:
		if ind>0:
			h=2
		else:
			k=1
		ddc=9-s.count(":")
	else:
		ddc=8-s.count(':')
	return (s[:ind]+ddc*tmp+s[ind+h:])[k:]

def t4(s):
	ls=len(s)
	if ls==4:
		return s
	return (4-ls)*'0'+s

def spu(s):
	ns=''
	fc=0	
	sc=s.find(':')
	while sc>0:
		ns+=t4(s[fc:sc])+':'
		fc=sc+1		
		sc=s.find(':',fc)
	ns+=t4(s[fc:])
	return ns

n=int(input())
v=[]
for c in range(n):
	v.append(spu(zr(input())))
for c in v:
	print(c)

for _ in range(int(input())):
    D = input().split(':')
    if not D[0]:
        D = D[1:]
    if not D[-1]:
        D.pop()
    
    n = len(D)
    for i in range(n):
        D[i] = D[i].zfill(4) if D[i] else '0000:' * (8 - n) + '0000'
    
    print(':'.join(D))

for _ in range(int(input())):
    D = input()
    print(':'.join(d.zfill(4) for d in D.replace('::', ':'*(9-D.count(':')))
                                        .split(':')))

import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

def do(s):
	r = []
	for i in s.split(':'):
		r.append('0'*(4-len(i))+i)
	return ':'.join(r)

n = mint()
for i in range(n):
	s = minp()
	m = s.find("::")
	if m != -1:
		print(do(s[:m])+':0000'*(8-s.count(':'))+':'+do(s[m+2:]))
	else:
		print(do(s))


n = int(input())
for i in range(n):
    ans = ''
    k =''
    s = input().split(':')
    c = m=0
    for g in range(len(s)):
        if s[g] != '':
            c += 1
    if c == 8:
        for j in range(c):
            s[j] = (4-len(s[j]))*'0' + s[j]
            ans += s[j] +':'
    else:
        k = (8-c)*'0000:'
        for j in range(len(s)):
            if s[j] == '':
                ans += k
                k = ''
                m = 1
            else:
                s[j] = (4-len(s[j]))*'0' + s[j]
                ans += s[j] +':'
    ans += k
    ans = ans[:-1]
    print(ans)