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

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

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

k = A("k")
d = B("d")
i = C("i")
l = B("l")
e = A("e")
c = B("c")
m = A("m")
a = A("a")
h = C("h")
b = C("b")

k.o = d
k.q = m
d.u = i
i.z = k
i.w = d
i.u = d
l.u = i
e.o = c
e.q = m
c.u = h
m.o = l
m.q = e
a.o = c
a.q = e
h.z = m
h.w = c
h.u = c
b.z = a
b.w = c
b.u = d
assert k.q.o.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.q: A = None
        self.txt = txt

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

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

k = A("k")
d = B("d")
i = C("i")
l = B("l")
e = A("e")
c = B("c")
m = A("m")
a = A("a")
h = C("h")
b = C("b")

k.o = d
k.q = m
d.u = i
i.z = k
i.w = d
i.u = d
l.u = i
e.o = c
e.q = m
c.u = h
m.o = l
m.q = e
a.o = c
a.q = e
h.z = m
h.w = c
h.u = c
b.z = a
b.w = c
b.u = d
assert k.q.o.u.u.txt == "d"