@Override
        protected void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
            if (times == 0) {
                context.write(new Text("grandchild"), new Text("grandparent"));
                times++;
            }

            int parentCount = 0;
            int childCount = 0;
            String[] parentNames = new String[10];
            String[] childNames = new String[10];
            Iterator<Text> iterator = values.iterator();
            while (iterator.hasNext()) {
                Text names = iterator.next();
                String parentName = "";
                String childName = "";

                String[] split = names.toString().split("\\+");
                if (split.length != 3)
                    continue;
                if (split[0].equals("1")) {
                    childNames[childCount] = split[1];
                    childCount++;
                }else {
                    parentNames[parentCount] = split[2];
                    parentCount++;
                }
            }

            if (parentCount != 0 && childCount != 0) {
                for (int i = 0; i < childCount; i++) {
                    for (int j = 0; j < parentCount; j++) {
                        context.write(new Text(childNames[i]) , new Text(parentNames[j]));
                    }
                }
            }
        }