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

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

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

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

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

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

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

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

j.s = d
d.v = g
g.p = d
g.t = j
assert d.v.t.s.txt == "d"