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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

l.o = a
m.z = a
a.r = m
assert a.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

l.o = a
m.z = a
a.r = m
assert a.r.z.r.txt == "m"