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

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

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

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

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

k.z = m
k.q = l
e.p = k
g.v = a
g.q = l
g.r = e
d.r = a
d.q = k
m.p = k
l.p = k
a.r = d
a.q = k
assert d.q.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.q: B = None
        self.txt = txt

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

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

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

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

k.z = m
k.q = l
e.p = k
g.v = a
g.q = l
g.r = e
d.r = a
d.q = k
m.p = k
l.p = k
a.r = d
a.q = k
assert d.q.q.p.txt == "k"