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

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: E = None
        self.s: E = None
        self.y: A = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
l = C("l")
m = D("m")
e = E("e")
c = D("c")
n = C("n")
k = A("k")
h = A("h")

f.w = b
f.y = e
f.r = m
b.x = n
b.q = e
b.s = e
b.y = f
l.q = n
l.p = c
m.o = e
e.x = f
e.o = c
c.o = e
n.q = l
n.p = c
k.w = b
k.y = e
k.r = m
h.w = b
h.y = e
h.r = m
assert m.o.x.w.s.x.y.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: E = None
        self.r: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: E = None
        self.s: E = None
        self.y: A = None
        self.txt = txt

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

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

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

f = A("f")
b = B("b")
l = C("l")
m = D("m")
e = E("e")
c = D("c")
n = C("n")
k = A("k")
h = A("h")

f.w = b
f.y = e
f.r = m
b.x = n
b.q = e
b.s = e
b.y = f
l.q = n
l.p = c
m.o = e
e.x = f
e.o = c
c.o = e
n.q = l
n.p = c
k.w = b
k.y = e
k.r = m
h.w = b
h.y = e
h.r = m
assert m.o.x.w.s.x.y.o.o.txt == "e"