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

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

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

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

a = A("a")
m = B("m")
h = C("h")
d = D("d")
l = C("l")
e = A("e")
b = C("b")
j = B("j")
f = D("f")
k = A("k")

a.v = k
a.q = f
m.v = d
m.w = j
m.q = f
h.x = f
h.u = k
h.z = j
h.s = l
d.w = f
d.v = e
l.x = d
l.u = e
l.z = j
l.s = h
e.v = a
e.q = f
b.x = d
b.u = a
b.z = j
b.s = l
j.v = f
j.q = f
j.w = m
f.w = d
f.v = a
k.v = a
k.q = f
assert h.x.v.v.q.v.q.v.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.q: D = None
        self.txt = txt

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

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

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

a = A("a")
m = B("m")
h = C("h")
d = D("d")
l = C("l")
e = A("e")
b = C("b")
j = B("j")
f = D("f")
k = A("k")

a.v = k
a.q = f
m.v = d
m.w = j
m.q = f
h.x = f
h.u = k
h.z = j
h.s = l
d.w = f
d.v = e
l.x = d
l.u = e
l.z = j
l.s = h
e.v = a
e.q = f
b.x = d
b.u = a
b.z = j
b.s = l
j.v = f
j.q = f
j.w = m
f.w = d
f.v = a
k.v = a
k.q = f
assert h.x.v.v.q.v.q.v.q.w.txt == "d"