class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: B = 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.p: C = None
        self.y: B = None
        self.q: C = None
        self.txt = txt

c = A("c")
d = B("d")
i = C("i")
a = C("a")
k = C("k")

c.q = d
c.t = d
d.u = a
i.p = a
i.q = a
i.y = d
a.p = i
a.q = i
a.y = d
k.p = i
k.y = d
k.q = a
assert i.y.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.t: B = 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.p: C = None
        self.y: B = None
        self.q: C = None
        self.txt = txt

c = A("c")
d = B("d")
i = C("i")
a = C("a")
k = C("k")

c.q = d
c.t = d
d.u = a
i.p = a
i.q = a
i.y = d
a.p = i
a.q = i
a.y = d
k.p = i
k.y = d
k.q = a
assert i.y.u.p.txt == "i"