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

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

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

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

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

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

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

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

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

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

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