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

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

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

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

j = A("j")
k = B("k")
e = C("e")
h = D("h")
a = D("a")
n = D("n")
b = C("b")
i = A("i")
d = A("d")

j.y = h
k.o = i
k.x = h
k.r = e
k.w = n
e.u = n
e.z = j
e.r = j
h.v = k
a.v = k
n.v = k
b.u = n
b.z = j
b.r = i
i.y = n
d.y = n
assert d.y.v.w.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

j = A("j")
k = B("k")
e = C("e")
h = D("h")
a = D("a")
n = D("n")
b = C("b")
i = A("i")
d = A("d")

j.y = h
k.o = i
k.x = h
k.r = e
k.w = n
e.u = n
e.z = j
e.r = j
h.v = k
a.v = k
n.v = k
b.u = n
b.z = j
b.r = i
i.y = n
d.y = n
assert d.y.v.w.v.txt == "k"