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

j = A("j")
b = B("b")
m = C("m")
a = A("a")
i = C("i")

j.y = m
b.q = a
m.t = b
m.y = b
a.y = m
i.t = b
i.y = b
assert i.y.q.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = 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.t: B = None
        self.y: B = None
        self.txt = txt

j = A("j")
b = B("b")
m = C("m")
a = A("a")
i = C("i")

j.y = m
b.q = a
m.t = b
m.y = b
a.y = m
i.t = b
i.y = b
assert i.y.q.y.y.txt == "b"