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

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

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

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

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

f.v = e
f.t = a
f.y = k
a.w = h
a.x = e
a.z = k
a.p = k
b.w = g
b.p = m
n.x = f
n.p = e
n.w = a
g.w = d
g.p = f
d.w = g
d.p = m
m.v = e
m.y = e
m.t = a
e.x = f
e.p = k
e.w = h
h.w = a
h.x = e
h.z = k
h.p = n
k.x = m
k.p = n
k.w = h
assert k.w.z.w.z.w.x.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.t: B = None
        self.y: D = None
        self.txt = txt

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

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

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

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

f.v = e
f.t = a
f.y = k
a.w = h
a.x = e
a.z = k
a.p = k
b.w = g
b.p = m
n.x = f
n.p = e
n.w = a
g.w = d
g.p = f
d.w = g
d.p = m
m.v = e
m.y = e
m.t = a
e.x = f
e.p = k
e.w = h
h.w = a
h.x = e
h.z = k
h.p = n
k.x = m
k.p = n
k.w = h
assert k.w.z.w.z.w.x.w.w.w.w.txt == "a"