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

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

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

a = A("a")
m = B("m")
l = C("l")

a.y = m
m.q = a
m.w = l
m.s = l
l.t = m
l.z = a
l.o = a
assert l.z.y.s.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

a = A("a")
m = B("m")
l = C("l")

a.y = m
m.q = a
m.w = l
m.s = l
l.t = m
l.z = a
l.o = a
assert l.z.y.s.txt == "l"