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

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

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

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

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

d.s = k
f.o = c
f.v = e
f.z = m
f.p = d
c.z = g
m.q = k
m.r = g
k.z = d
g.s = l
l.z = d
e.q = l
e.r = d
j.o = c
j.v = e
j.z = e
j.p = g
a.o = c
a.v = e
a.z = e
a.p = g
assert d.s.z.s.z.s.z.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

d.s = k
f.o = c
f.v = e
f.z = m
f.p = d
c.z = g
m.q = k
m.r = g
k.z = d
g.s = l
l.z = d
e.q = l
e.r = d
j.o = c
j.v = e
j.z = e
j.p = g
a.o = c
a.v = e
a.z = e
a.p = g
assert d.s.z.s.z.s.z.s.z.txt == "d"