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

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

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

a = A("a")
c = B("c")
b = C("b")

a.p = b
c.o = a
b.t = c
assert b.t.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
b = C("b")

a.p = b
c.o = a
b.t = c
assert b.t.o.p.txt == "b"