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

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

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

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

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

f.v = n
f.z = a
a.v = h
k.v = d
k.s = b
k.r = a
i.u = n
i.v = d
c.u = n
c.v = d
b.v = c
b.s = n
b.r = a
n.v = c
n.s = k
n.r = a
h.v = k
h.z = a
d.u = b
d.v = c
g.v = b
g.z = a
assert k.r.v.z.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.z: B = None
        self.txt = txt

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

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

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

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

f.v = n
f.z = a
a.v = h
k.v = d
k.s = b
k.r = a
i.u = n
i.v = d
c.u = n
c.v = d
b.v = c
b.s = n
b.r = a
n.v = c
n.s = k
n.r = a
h.v = k
h.z = a
d.u = b
d.v = c
g.v = b
g.z = a
assert k.r.v.z.v.v.v.v.v.txt == "d"