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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: C = None
        self.o: C = None
        self.y: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.t: B = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: C = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

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

class B:
    def __init__(self, txt: str):
        self.w: A = None
        self.r: C = None
        self.o: C = None
        self.y: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: B = None
        self.t: B = None
        self.v: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.y: C = None
        self.x: C = None
        self.o: C = None
        self.txt = txt

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

n.s = c
n.p = c
b.w = n
b.r = g
b.o = g
b.y = d
g.o = b
g.x = b
g.t = b
g.v = k
d.z = g
d.y = g
d.x = g
d.o = c
j.z = g
j.o = g
j.y = c
j.x = c
k.z = g
k.y = c
k.x = c
k.o = c
f.z = c
f.o = c
f.y = g
f.x = g
c.o = b
c.x = b
c.t = b
c.v = j
assert f.y.x.y.x.x.w.s.txt == "c"