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

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: C = None
        self.q: B = None
        self.txt = txt

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

h = A("h")
l = B("l")
c = C("c")
a = B("a")
i = C("i")
b = B("b")
f = A("f")
m = A("m")

h.y = c
l.p = c
l.y = c
l.q = b
c.t = a
c.z = m
a.p = i
a.y = c
a.q = l
i.t = l
i.z = h
b.p = i
b.y = i
b.q = a
f.y = c
m.y = c
assert i.t.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: C = None
        self.q: B = None
        self.txt = txt

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

h = A("h")
l = B("l")
c = C("c")
a = B("a")
i = C("i")
b = B("b")
f = A("f")
m = A("m")

h.y = c
l.p = c
l.y = c
l.q = b
c.t = a
c.z = m
a.p = i
a.y = c
a.q = l
i.t = l
i.z = h
b.p = i
b.y = i
b.q = a
f.y = c
m.y = c
assert i.t.q.q.q.q.txt == "b"