import java.util.ArrayList;
import java.util.List;
public class Main {
public static void main
(String[] args
) { List<int[]> data1 = loadData1();
List<int[]> data2 = loadData2();
List<int[]> joinedData = joinData(data1, data2);
for (int[] row : joinedData) {
System.
out.
println("(" + row
[0] + "," + row
[1] + "," + row
[2] + "," + row
[3] + "," + row
[4] + ")"); }
}
private static List<int[]> loadData1() {
List<int[]> data1 = new ArrayList<>();
data1.add(new int[]{1, 2, 3});
data1.add(new int[]{4, 2, 1});
data1.add(new int[]{8, 3, 4});
data1.add(new int[]{4, 3, 3});
data1.add(new int[]{7, 2, 5});
data1.add(new int[]{8, 4, 3});
return data1;
}
private static List<int[]> loadData2() {
List<int[]> data2 = new ArrayList<>();
data2.add(new int[]{2, 4});
data2.add(new int[]{8, 9});
data2.add(new int[]{1, 3});
data2.add(new int[]{2, 7});
data2.add(new int[]{2, 9});
data2.add(new int[]{4, 6});
data2.add(new int[]{4, 9});
return data2;
}
private static List<int[]> joinData(List<int[]> data1, List<int[]> data2) {
List<int[]> result = new ArrayList<>();
for (int[] rowA : data1) {
for (int[] rowB : data2) {
if (rowA[0] == rowB[0]) {
result.add(new int[]{rowA[0], rowA[1], rowA[2], rowB[1], rowB[1]});
}
}
}
return result;
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CmltcG9ydCBqYXZhLnV0aWwuTGlzdDsKCnB1YmxpYyBjbGFzcyBNYWluIHsKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBMaXN0PGludFtdPiBkYXRhMSA9IGxvYWREYXRhMSgpOwogICAgICAgIExpc3Q8aW50W10+IGRhdGEyID0gbG9hZERhdGEyKCk7CiAgICAgICAgCiAgICAgICAgTGlzdDxpbnRbXT4gam9pbmVkRGF0YSA9IGpvaW5EYXRhKGRhdGExLCBkYXRhMik7CgogICAgICAgIGZvciAoaW50W10gcm93IDogam9pbmVkRGF0YSkgewogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oIigiICsgcm93WzBdICsgIiwiICsgcm93WzFdICsgIiwiICsgcm93WzJdICsgIiwiICsgcm93WzNdICsgIiwiICsgcm93WzRdICsgIikiKTsKICAgICAgICB9CiAgICB9CgogICAgcHJpdmF0ZSBzdGF0aWMgTGlzdDxpbnRbXT4gbG9hZERhdGExKCkgewogICAgICAgIExpc3Q8aW50W10+IGRhdGExID0gbmV3IEFycmF5TGlzdDw+KCk7CiAgICAgICAgZGF0YTEuYWRkKG5ldyBpbnRbXXsxLCAyLCAzfSk7CiAgICAgICAgZGF0YTEuYWRkKG5ldyBpbnRbXXs0LCAyLCAxfSk7CiAgICAgICAgZGF0YTEuYWRkKG5ldyBpbnRbXXs4LCAzLCA0fSk7CiAgICAgICAgZGF0YTEuYWRkKG5ldyBpbnRbXXs0LCAzLCAzfSk7CiAgICAgICAgZGF0YTEuYWRkKG5ldyBpbnRbXXs3LCAyLCA1fSk7CiAgICAgICAgZGF0YTEuYWRkKG5ldyBpbnRbXXs4LCA0LCAzfSk7CiAgICAgICAgcmV0dXJuIGRhdGExOwogICAgfQoKICAgIHByaXZhdGUgc3RhdGljIExpc3Q8aW50W10+IGxvYWREYXRhMigpIHsKICAgICAgICBMaXN0PGludFtdPiBkYXRhMiA9IG5ldyBBcnJheUxpc3Q8PigpOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117MiwgNH0pOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117OCwgOX0pOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117MSwgM30pOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117MiwgN30pOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117MiwgOX0pOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117NCwgNn0pOwogICAgICAgIGRhdGEyLmFkZChuZXcgaW50W117NCwgOX0pOwogICAgICAgIHJldHVybiBkYXRhMjsKICAgIH0KCiAgICBwcml2YXRlIHN0YXRpYyBMaXN0PGludFtdPiBqb2luRGF0YShMaXN0PGludFtdPiBkYXRhMSwgTGlzdDxpbnRbXT4gZGF0YTIpIHsKICAgICAgICBMaXN0PGludFtdPiByZXN1bHQgPSBuZXcgQXJyYXlMaXN0PD4oKTsKICAgICAgICAKICAgICAgICBmb3IgKGludFtdIHJvd0EgOiBkYXRhMSkgewogICAgICAgICAgICBmb3IgKGludFtdIHJvd0IgOiBkYXRhMikgewogICAgICAgICAgICAgICAgaWYgKHJvd0FbMF0gPT0gcm93QlswXSkgewogICAgICAgICAgICAgICAgICAgIHJlc3VsdC5hZGQobmV3IGludFtde3Jvd0FbMF0sIHJvd0FbMV0sIHJvd0FbMl0sIHJvd0JbMV0sIHJvd0JbMV19KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICAKICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgfQp9Cg==
(1,2,3,3,3)
(4,2,1,6,6)
(4,2,1,9,9)
(8,3,4,9,9)
(4,3,3,6,6)
(4,3,3,9,9)
(8,4,3,9,9)