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

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

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

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

c = A("c")
i = B("i")
f = C("f")
a = D("a")
n = B("n")
l = A("l")
b = D("b")
k = A("k")

c.p = a
c.q = i
i.v = f
f.y = k
a.w = k
a.q = i
a.s = c
n.v = f
l.p = a
l.q = n
b.w = c
b.q = n
b.s = k
k.p = b
k.q = n
assert b.s.q.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.q: B = None
        self.txt = txt

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

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

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

c = A("c")
i = B("i")
f = C("f")
a = D("a")
n = B("n")
l = A("l")
b = D("b")
k = A("k")

c.p = a
c.q = i
i.v = f
f.y = k
a.w = k
a.q = i
a.s = c
n.v = f
l.p = a
l.q = n
b.w = c
b.q = n
b.s = k
k.p = b
k.q = n
assert b.s.q.v.y.txt == "k"