#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int c = 0;
    for (int i = 0; i < s.length(); i++)
      if (s[i] == ':') c++;
    int req = 7 - c;
    vector<char> fullstr(40);
    int j = s.length() - 1, i = 38;
    c = 0;
    for (; i >= 0; i--, j--) {
      if (j < 0) break;
      if (c == 4 && s[j] == ':') {
        fullstr[i] = ':';
        c = 0;
      } else if (c != 4 && s[j] == ':') {
        int tmp = 4 - c;
        for (int k = 0; k < tmp; k++, i--) {
          fullstr[i] = '0';
        }
        fullstr[i] = ':';
        c = 0;
      } else {
        fullstr[i] = s[j];
        c++;
      }
      if (s[j] == ':' && s[j - 1] == ':') {
        i--;
        for (int k = 0; k < req + 1; k++) {
          for (int v = 0; v < 4; v++, i--) {
            fullstr[i] = '0';
          }
          fullstr[i] = ':';
          i--;
        }
        i++;
        j--;
      }
    }
    if (i != -1) {
      for (; i >= 0; i--) {
        fullstr[i] = '0';
      }
    }
    for (i = 0; i < 39; i++) {
      cout << fullstr[i];
    }
    cout << endl;
  }
  return 0;
}
