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

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

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

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

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

e.w = l
e.x = h
n.r = l
n.y = e
n.x = e
n.z = d
d.y = j
h.v = m
j.v = d
m.y = h
l.r = n
l.y = e
l.x = e
l.z = m
assert e.x.v.y.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: D = None
        self.txt = txt

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

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

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

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

e.w = l
e.x = h
n.r = l
n.y = e
n.x = e
n.z = d
d.y = j
h.v = m
j.v = d
m.y = h
l.r = n
l.y = e
l.x = e
l.z = m
assert e.x.v.y.v.y.txt == "h"