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

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

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

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

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

i.y = b
i.q = g
c.s = e
f.v = i
f.z = d
e.s = j
e.x = i
e.r = g
e.w = g
j.s = g
b.v = i
b.z = f
k.v = i
k.z = b
d.v = i
d.z = f
g.s = j
g.x = i
g.r = e
g.w = e
n.s = g
assert f.v.q.w.r.w.r.x.y.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: D = None
        self.txt = txt

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

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

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

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

i.y = b
i.q = g
c.s = e
f.v = i
f.z = d
e.s = j
e.x = i
e.r = g
e.w = g
j.s = g
b.v = i
b.z = f
k.v = i
k.z = b
d.v = i
d.z = f
g.s = j
g.x = i
g.r = e
g.w = e
n.s = g
assert f.v.q.w.r.w.r.x.y.z.z.txt == "d"