class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: B = None
        self.q: C = None
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

m.u = n
m.o = n
m.q = e
m.v = a
n.o = m
n.r = m
n.y = j
e.z = m
a.v = m
b.w = a
j.w = a
assert j.w.v.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: B = None
        self.q: C = None
        self.v: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

m.u = n
m.o = n
m.q = e
m.v = a
n.o = m
n.r = m
n.y = j
e.z = m
a.v = m
b.w = a
j.w = a
assert j.w.v.u.o.txt == "m"