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

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

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

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

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

n = A("n")
d = B("d")
e = C("e")
j = D("j")
i = E("i")

n.y = i
d.x = e
d.p = i
d.w = j
e.p = d
e.o = d
e.q = i
j.r = d
j.x = e
j.u = n
i.x = e
assert e.o.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.txt = txt

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

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

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

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

n = A("n")
d = B("d")
e = C("e")
j = D("j")
i = E("i")

n.y = i
d.x = e
d.p = i
d.w = j
e.p = d
e.o = d
e.q = i
j.r = d
j.x = e
j.u = n
i.x = e
assert e.o.w.u.txt == "n"