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

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

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

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

m.p = l
m.o = l
l.t = m
e.t = m
assert l.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: B = None
        self.txt = txt

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

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

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

m.p = l
m.o = l
l.t = m
e.t = m
assert l.t.o.t.txt == "m"