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

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

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

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

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

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

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

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

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

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

k.q = a
k.y = l
e.s = a
e.p = l
m.q = e
m.v = k
b.x = a
l.s = a
l.p = e
n.q = l
n.v = a
d.q = l
d.v = a
g.x = k
a.q = k
a.y = l
assert b.x.y.p.s.q.txt == "k"