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

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

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

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

k = A("k")
b = B("b")
a = C("a")
d = D("d")
g = D("g")
i = A("i")
n = B("n")

k.z = n
b.q = d
b.y = n
b.x = n
a.p = n
a.s = n
a.v = b
d.o = g
d.z = g
g.o = d
g.z = d
i.z = n
n.q = d
n.y = b
n.x = b
assert i.z.q.z.o.z.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

k = A("k")
b = B("b")
a = C("a")
d = D("d")
g = D("g")
i = A("i")
n = B("n")

k.z = n
b.q = d
b.y = n
b.x = n
a.p = n
a.s = n
a.v = b
d.o = g
d.z = g
g.o = d
g.z = d
i.z = n
n.q = d
n.y = b
n.x = b
assert i.z.q.z.o.z.o.txt == "d"