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

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

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

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

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

e = A("e")
b = B("b")
f = C("f")
a = D("a")
c = E("c")
m = D("m")

e.p = b
e.o = a
b.y = e
b.o = e
b.s = e
b.u = m
f.y = e
f.w = e
a.q = m
a.u = m
a.v = e
a.w = b
c.x = a
m.q = a
m.u = a
m.v = e
m.w = b
assert a.q.q.u.w.s.o.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

e = A("e")
b = B("b")
f = C("f")
a = D("a")
c = E("c")
m = D("m")

e.p = b
e.o = a
b.y = e
b.o = e
b.s = e
b.u = m
f.y = e
f.w = e
a.q = m
a.u = m
a.v = e
a.w = b
c.x = a
m.q = a
m.u = a
m.v = e
m.w = b
assert a.q.q.u.w.s.o.txt == "a"