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

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

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

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

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

n.s = c
m.z = e
m.q = c
m.v = g
m.w = d
f.q = a
e.y = a
d.s = f
k.s = f
a.y = e
c.q = a
g.s = f
assert g.s.q.y.y.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

n.s = c
m.z = e
m.q = c
m.v = g
m.w = d
f.q = a
e.y = a
d.s = f
k.s = f
a.y = e
c.q = a
g.s = f
assert g.s.q.y.y.y.y.y.y.txt == "a"