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

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.x: A = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
m = C("m")
d = D("d")
j = E("j")

b.y = d
b.q = m
b.r = j
e.r = j
e.z = j
e.x = b
m.r = j
m.u = j
m.o = j
m.s = d
m.q = d
d.x = m
d.o = e
j.w = e
j.t = b
j.p = b
j.q = d
assert m.s.x.q.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: C = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.x: A = None
        self.txt = txt

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

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

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

b = A("b")
e = B("e")
m = C("m")
d = D("d")
j = E("j")

b.y = d
b.q = m
b.r = j
e.r = j
e.z = j
e.x = b
m.r = j
m.u = j
m.o = j
m.s = d
m.q = d
d.x = m
d.o = e
j.w = e
j.t = b
j.p = b
j.q = d
assert m.s.x.q.o.x.txt == "b"