#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k = -1, t, len, ln, rn;
  string line, ss = "::", left, right, mid;
  cin >> n;
  bool first;
  for (t = 0; t < n; ++t) {
    cin >> line;
    k = -1;
    for (i = 0; i < line.length() - 1; ++i) {
      if (line.compare(i, 2, ss) == 0) {
        k = i;
        break;
      }
    }
    left = "";
    right = "";
    ln = 0;
    rn = 0;
    mid = "";
    first = true;
    j = 0;
    if (k == -1) {
      for (i = 0; i < line.length(); ++i) {
        if (line[i] == ':') {
          if (first) {
            first = false;
          } else {
            left += ":";
          }
          len = i - j;
          left.append(4 - len, '0');
          left += line.substr(j, len);
          j = i + 1;
          ++ln;
        }
      }
      if (first) {
        first = false;
      } else {
        left += ":";
      }
      len = i - j;
      left.append(4 - len, '0');
      left += line.substr(j, len);
      j = i + 1;
      ++ln;
      cout << left << endl;
    } else {
      for (i = 0; i < k; ++i) {
        if (line[i] == ':') {
          if (first) {
            first = false;
          } else {
            left += ":";
          }
          len = i - j;
          left.append(4 - len, '0');
          left += line.substr(j, len);
          j = i + 1;
          ++ln;
        }
      }
      if (k >= i) {
        if (first) {
          first = false;
        } else {
          left += ":";
        }
        len = i - j;
        left.append(4 - len, '0');
        left += line.substr(j, len);
        j = i + 1;
        ++ln;
      }
      j = k + 2;
      for (i = k + 2; i < line.length(); ++i) {
        if (line[i] == ':') {
          if (first) {
            first = false;
          } else {
            right += ":";
          }
          len = i - j;
          right.append(4 - len, '0');
          right += line.substr(j, len);
          j = i + 1;
          ++rn;
        }
      }
      if (line.length() - 1 >= k + 2) {
        if (first) {
          first = false;
        } else {
          right += ":";
        }
        len = i - j;
        right.append(4 - len, '0');
        right += line.substr(j, len);
        j = i + 1;
        ++rn;
      }
      for (i = 0; i < 8 - ln - rn; ++i) {
        if (first) {
          first = false;
        } else {
          mid += ":";
        }
        mid += "0000";
      }
      cout << left + mid + right << endl;
    }
  }
  return 0;
}
