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

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

d = A("d")
n = B("n")
g = C("g")
c = D("c")
l = B("l")
k = D("k")
a = C("a")

d.u = g
d.w = g
n.q = c
g.u = l
g.w = l
c.v = k
c.p = g
c.s = l
l.q = c
k.v = c
k.p = a
k.s = n
a.u = l
a.w = n
assert a.u.q.p.u.q.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.w: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

d = A("d")
n = B("n")
g = C("g")
c = D("c")
l = B("l")
k = D("k")
a = C("a")

d.u = g
d.w = g
n.q = c
g.u = l
g.w = l
c.v = k
c.p = g
c.s = l
l.q = c
k.v = c
k.p = a
k.s = n
a.u = l
a.w = n
assert a.u.q.p.u.q.s.q.txt == "c"