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

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

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

f = A("f")
b = B("b")
a = C("a")
j = C("j")

f.p = b
b.v = f
b.t = j
a.y = b
a.p = b
j.y = b
j.p = b
assert b.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

f = A("f")
b = B("b")
a = C("a")
j = C("j")

f.p = b
b.v = f
b.t = j
a.y = b
a.p = b
j.y = b
j.p = b
assert b.v.p.v.txt == "f"