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

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

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

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

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

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

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

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

a.u = e
a.y = d
d.q = e
b.z = k
b.u = e
b.p = m
k.q = e
e.u = a
e.y = m
h.q = a
c.z = h
c.p = h
c.u = a
m.q = e
i.z = k
i.u = e
i.p = d
assert h.q.u.u.y.txt == "d"