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

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: B = None
        self.p: B = None
        self.u: C = None
        self.txt = txt

e = A("e")
b = B("b")
a = C("a")
g = D("g")

e.t = b
e.x = a
b.s = a
b.t = g
b.o = g
b.w = e
a.w = b
a.t = b
a.s = g
g.x = e
g.s = b
g.p = b
g.u = a
assert e.t.w.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: B = None
        self.p: B = None
        self.u: C = None
        self.txt = txt

e = A("e")
b = B("b")
a = C("a")
g = D("g")

e.t = b
e.x = a
b.s = a
b.t = g
b.o = g
b.w = e
a.w = b
a.t = b
a.s = g
g.x = e
g.s = b
g.p = b
g.u = a
assert e.t.w.x.txt == "a"