#include <bits/stdc++.h>
using namespace std;
int n;
char str[1010];
int main() {
  int mark, pre;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      scanf("%s", str);
      int left, right, pos;
      left = right = 0;
      pos = -1;
      mark = 0;
      int len = strlen(str);
      for (int i = 0; i < len - 1; i++) {
        if (str[i] == ':' && str[i + 1] == ':') {
          pos = i;
          mark = 1;
          if (i != 0) left++;
          if (i + 1 != len - 1) right++;
          i++;
          continue;
        } else if (str[i] == ':' && !mark)
          left++;
        else if (str[i] == ':' && mark)
          right++;
      }
      if (pos == -1) {
        pre = 0;
        for (int i = 0; i < len; i++) {
          if (str[i] == ':' || i == len - 1) {
            if (i == len - 1) i = len;
            int tmp = 4 - (i - pre);
            for (int j = 0; j < tmp; j++) printf("0");
            for (int j = pre; j < i; j++) printf("%c", str[j]);
            if (i != len) printf(":");
            pre = i + 1;
          }
        }
        printf("\n");
      } else {
        int num = 8 - left - right;
        if (num == 8)
          printf("0000:0000:0000:0000:0000:0000:0000:0000\n");
        else {
          pre = 0;
          for (int i = 0; i < len; i++) {
            if (i != pos + 1) {
              if (i != 0 && str[i] == ':' || i == len - 1) {
                if (i == len - 1) i = len;
                int tmp = 4 - (i - pre);
                for (int j = 0; j < tmp; j++) printf("0");
                for (int j = pre; j < i; j++) printf("%c", str[j]);
                if (i != pos && i != len) printf(":");
                if (i != pos) pre = i + 1;
              }
            } else {
              for (int j = 0; j < num; j++) {
                if (j == 0 && pos == 0)
                  printf("0000");
                else
                  printf(":0000");
              }
              pre = i + 1;
              if (i + 1 != len) printf(":");
            }
          }
          printf("\n");
        }
      }
    }
  }
  return 0;
}
