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

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

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

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

l = A("l")
c = B("c")
e = C("e")
g = D("g")
m = C("m")
d = B("d")
k = D("k")

l.q = c
c.p = m
e.x = g
e.s = d
e.u = k
g.s = d
m.x = k
m.s = c
m.u = g
d.p = e
k.s = d
assert c.p.x.s.p.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

l = A("l")
c = B("c")
e = C("e")
g = D("g")
m = C("m")
d = B("d")
k = D("k")

l.q = c
c.p = m
e.x = g
e.s = d
e.u = k
g.s = d
m.x = k
m.s = c
m.u = g
d.p = e
k.s = d
assert c.p.x.s.p.u.txt == "k"