class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.o: A = None
        self.x: A = 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.o: D = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
j = B("j")
n = C("n")
f = D("f")
c = C("c")
m = B("m")
d = C("d")
l = A("l")
a = D("a")

e.w = j
e.y = m
e.o = l
e.x = l
j.x = f
n.o = a
n.r = l
f.y = c
c.o = a
c.r = e
m.x = f
d.o = a
d.r = e
l.w = j
l.y = m
l.o = e
l.x = e
a.y = d
assert e.w.x.y.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.y: B = None
        self.o: A = None
        self.x: A = 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.o: D = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
j = B("j")
n = C("n")
f = D("f")
c = C("c")
m = B("m")
d = C("d")
l = A("l")
a = D("a")

e.w = j
e.y = m
e.o = l
e.x = l
j.x = f
n.o = a
n.r = l
f.y = c
c.o = a
c.r = e
m.x = f
d.o = a
d.r = e
l.w = j
l.y = m
l.o = e
l.x = e
a.y = d
assert e.w.x.y.r.o.txt == "l"