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

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

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

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

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

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

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

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

g.y = e
e.o = a
e.t = a
a.x = e
d.y = e
assert g.y.o.x.o.txt == "a"