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

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

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

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

a = A("a")
c = B("c")
d = C("d")
g = D("g")

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

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

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

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

a = A("a")
c = B("c")
d = C("d")
g = D("g")

a.t = c
c.s = a
c.t = d
d.o = g
g.o = c
g.y = a
assert a.t.s.t.s.txt == "a"