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

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

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

i = A("i")
a = B("a")
d = C("d")
g = C("g")

i.y = a
a.t = i
a.v = d
d.x = a
d.r = a
d.o = i
g.x = a
g.r = a
g.o = i
assert g.r.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
d = C("d")
g = C("g")

i.y = a
a.t = i
a.v = d
d.x = a
d.r = a
d.o = i
g.x = a
g.r = a
g.o = i
assert g.r.t.y.txt == "a"