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

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: E = None
        self.s: C = None
        self.r: E = None
        self.y: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: D = None
        self.r: B = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
f = D("f")
h = E("h")

n.x = h
n.p = h
n.u = h
d.x = n
d.u = f
m.q = f
f.o = h
f.u = h
f.r = h
f.y = h
f.s = m
h.q = f
h.w = f
h.r = d
assert m.q.u.r.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: E = None
        self.p: E = None
        self.u: E = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: E = None
        self.s: C = None
        self.r: E = None
        self.y: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.q: D = None
        self.w: D = None
        self.r: B = None
        self.txt = txt

n = A("n")
d = B("d")
m = C("m")
f = D("f")
h = E("h")

n.x = h
n.p = h
n.u = h
d.x = n
d.u = f
m.q = f
f.o = h
f.u = h
f.r = h
f.y = h
f.s = m
h.q = f
h.w = f
h.r = d
assert m.q.u.r.x.u.txt == "h"