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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: A = None
        self.x: C = None
        self.o: B = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
e = C("e")
b = D("b")
n = C("n")
h = C("h")
d = B("d")
f = A("f")
j = B("j")

i.y = f
i.o = h
a.w = i
a.z = i
a.x = n
a.o = d
e.u = h
b.z = a
n.u = h
h.u = n
d.w = f
d.z = f
d.x = h
d.o = j
f.y = i
f.o = n
j.w = i
j.z = f
j.x = h
j.o = d
assert h.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.z: A = None
        self.x: C = None
        self.o: B = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
e = C("e")
b = D("b")
n = C("n")
h = C("h")
d = B("d")
f = A("f")
j = B("j")

i.y = f
i.o = h
a.w = i
a.z = i
a.x = n
a.o = d
e.u = h
b.z = a
n.u = h
h.u = n
d.w = f
d.z = f
d.x = h
d.o = j
f.y = i
f.o = n
j.w = i
j.z = f
j.x = h
j.o = d
assert h.u.u.u.u.u.txt == "n"