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

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

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

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

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

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

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

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

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

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

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

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

e.r = m
e.o = l
d.x = l
h.v = m
h.o = f
h.w = e
l.o = f
l.q = d
l.x = e
n.p = m
n.q = m
n.s = d
m.r = e
m.o = l
f.v = m
f.w = m
f.o = h
assert f.o.o.w.txt == "m"