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

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

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

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

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

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

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

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

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

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

e.r = n
e.t = n
b.u = e
n.p = a
n.w = b
n.x = b
n.o = e
a.x = e
a.p = n
assert a.p.x.u.txt == "e"