#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void upd_min(T& dest, const T& src) {
  if (src < dest) dest = src;
}
template <typename T>
inline void upd_max(T& dest, const T& src) {
  if (dest < src) dest = src;
}
template <typename T, int n>
struct Queue {
  T q[n];
  int qf, qr;
  Queue() : qf(0), qr(0) {}
  inline void clear() { qf = qr = 0; }
  inline bool empty() { return qf == qr; }
  inline void push(const T& data) {
    q[qr] = data;
    if (++qr == n) qr = 0;
  }
  inline void pop() {
    if (++qf == n) qf = 0;
  }
  inline T& front() { return q[qf]; }
};
template <int maxN>
struct Disjoint {
  int N;
  int p[maxN];
  inline void init(int n) {
    N = n;
    for (int i = 0; i < N; ++i) p[i] = i;
  }
  inline int root(int i) {
    for (; i != p[i]; i = p[i]) p[i] = p[p[i]];
    return i;
  }
  inline void unite(int a, int b) { p[root(b)] = root(a); }
  inline bool query(int a, int b) { return root(a) == root(b); }
};
template <typename T, int N>
struct Stack {
  T s[N];
  int index;
  Stack() : index(0) {}
  inline void clear() { index = 0; }
  inline T& top() { return s[index]; }
  inline void pop() { --index; }
  inline bool empty() { return index == 0; }
  inline void push(T data) { s[++index] = data; }
};
int nextInt() {
  int ret;
  char c;
  while (c = getchar(), c < '0' || c > '9')
    ;
  ret = c - '0';
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + c - '0';
  return ret;
}
const int inf = 0x7f7f7f7f;
int N;
char c[255];
int main() {
  N = nextInt();
  for (int t = 1; t <= N; t++) {
    scanf("%s", c);
    int ll = strlen(c);
    int sf(0);
    for (int i = 0; i < ll; i++)
      if (c[i] == ':') sf++;
    if (sf == 2 && ll == 2) {
      printf("0000:0000:0000:0000:0000:0000:0000:0000\n");
    } else {
      int ind(1), k(1);
      for (int i = 1; i < ll; i++) {
        if (c[i] != ':')
          ind++;
        else {
          if (c[i - 1] == ':') {
            if (i == 1) sf--;
            for (int j = 1; j <= 8 - sf; j++) {
              if (k != 1) printf(":");
              printf("0000");
              k++;
            }
          } else {
            if (k != 1) printf(":");
            k++;
            for (int j = 1; j <= 4 - ind; j++) printf("0");
            for (int j = 1; j <= ind; j++) printf("%c", c[i - ind - 1 + j]);
          }
          ind = 0;
        }
      }
      if (k == 8) {
        printf(":");
        for (int j = 1; j <= 4 - ind; j++) printf("0");
        for (int j = 1; j <= ind; j++) printf("%c", c[ll - ind - 1 + j]);
      }
      printf("\n");
    }
  }
  return 0;
}
