#include <bits/stdc++.h>
using namespace std;
int t, n, l, r, pos;
char in[1000], ans[1000][10];
bool back;
int main() {
  scanf("%d", &t);
  while (t--) {
    back = false;
    scanf("%s", in);
    n = strlen(in);
    for (int i = 1; i <= 8; i++)
      for (int j = 0; j <= 3; j++) ans[i][j] = '0';
    pos = 1;
    l = r = 0;
    for (int i = 0; i < n;) {
      if (in[i] == ':') {
        if (in[i + 1] == ':') {
          l = i + 2;
          i += 2;
          back = true;
          pos = 8;
        } else {
          l = i + 1;
          i++;
        }
        continue;
      }
      while (i + 1 < n && in[i + 1] != ':') i++;
      r = i;
      int x = 4 - (r - l + 1);
      for (int j = r; j >= l; j--) {
        ans[pos][j - l + x] = in[j];
      }
      if (!back)
        pos++;
      else
        pos--;
      i++;
    }
    if (!back) {
      for (int i = 1; i <= 8; i++) {
        if (i != 1) putchar(':');
        for (int j = 0; j <= 3; j++) putchar(ans[i][j]);
      }
    } else {
      for (int i = 1; i <= pos; i++) {
        if (i != 1) putchar(':');
        for (int j = 0; j <= 3; j++) putchar(ans[i][j]);
      }
      for (int i = 8; i >= pos + 1; i--) {
        putchar(':');
        for (int j = 0; j <= 3; j++) putchar(ans[i][j]);
      }
    }
    puts("");
  }
  return 0;
}
