

import sys

with sys.stdin as f:
    for line in f:
        if line.startswith('#'):
            # header
            if line.startswith('#CHROM'):
                CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, *all_samples = line.split()

                # TODO: seperate males and females:
                males = []
                females = []

            print(line, end='')
        else:
            # calls
            CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, *calls = line.split()

            # get female alleles
            female_alleles = []
            for i, sample, in enumerate(all_samples):
                alleles = calls[i].split('/')
                if sample in females:
                    female_alleles.extend(alleles)
            female_alleles = set(female_alleles)

            for i, sample, in enumerate(all_samples):
                if calls[i] == './.':
                    continue
                alleles = calls[i].split('/')
                if len(alleles) > 1:
                    if len(female_alleles) > 1:
                        calls[i] =  './.'
                    else:
                        a = list(female_alleles)[0]
                        calls[i] == f'{a}/{a}'

            print('\t'.join([CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, *calls]))




import sys

with sys.stdin as f:
    for line in f:
        if line.startswith('#'):
            # header
            if line.startswith('#CHROM'):
                CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, *all_samples = line.split()

                # TODO: seperate males and females:
                males = []
                females = []

            print(line, end='')
        else:
            # calls
            CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, *calls = line.split()

            # get female alleles
            female_alleles = []
            for i, sample, in enumerate(all_samples):
                alleles = calls[i].split('/')
                if sample in females:
                    female_alleles.extend(alleles)
            female_alleles = set(female_alleles)

            for i, sample, in enumerate(all_samples):
                if calls[i] == './.':
                    continue
                alleles = calls[i].split('/')
                if len(alleles) > 1:
                    if len(female_alleles) > 1:
                        calls[i] =  './.'
                    else:
                        a = list(female_alleles)[0]
                        calls[i] == f'{a}/{a}'

            print('\t'.join([CHROM, POS, ID, REF, ALT, QUAL, FILTER, INFO, FORMAT, *calls]))


# header # TODO: seperate males and females: # calls # get female alleles