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

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

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

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

g.t = h
g.v = d
j.x = g
d.r = j
h.x = g
assert j.x.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.v: C = None
        self.txt = txt

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

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

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

g.t = h
g.v = d
j.x = g
d.r = j
h.x = g
assert j.x.v.r.txt == "j"