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

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

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

f = A("f")
g = B("g")
d = C("d")
j = B("j")

f.t = g
g.p = f
g.r = d
g.v = d
d.t = f
d.o = g
d.w = j
j.p = f
j.r = d
j.v = d
assert g.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

f = A("f")
g = B("g")
d = C("d")
j = B("j")

f.t = g
g.p = f
g.r = d
g.v = d
d.t = f
d.o = g
d.w = j
j.p = f
j.r = d
j.v = d
assert g.v.o.v.txt == "d"