class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: A = None
        self.o: D = None
        self.txt = txt

m = A("m")
k = B("k")
d = C("d")
n = D("n")
b = A("b")
e = B("e")
g = C("g")
i = D("i")

m.o = k
m.u = b
k.u = g
k.z = i
d.y = m
n.x = i
n.o = i
n.u = b
b.o = k
b.u = m
e.u = g
e.z = n
g.y = m
i.x = n
i.o = n
i.u = b
assert k.u.y.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: A = None
        self.o: D = None
        self.txt = txt

m = A("m")
k = B("k")
d = C("d")
n = D("n")
b = A("b")
e = B("e")
g = C("g")
i = D("i")

m.o = k
m.u = b
k.u = g
k.z = i
d.y = m
n.x = i
n.o = i
n.u = b
b.o = k
b.u = m
e.u = g
e.z = n
g.y = m
i.x = n
i.o = n
i.u = b
assert k.u.y.o.u.txt == "g"