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

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

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

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

n = A("n")
i = B("i")
c = C("c")
a = D("a")
l = C("l")
d = C("d")
h = D("h")
j = D("j")
k = D("k")

n.q = d
n.w = d
n.t = i
i.y = d
i.q = n
i.t = j
c.r = i
c.p = i
a.t = k
a.w = l
a.q = n
l.r = i
l.p = i
d.r = i
d.p = i
h.t = a
h.w = l
h.q = n
j.t = h
j.w = d
j.q = n
k.t = a
k.w = c
k.q = n
assert l.r.q.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.w: C = None
        self.t: B = None
        self.txt = txt

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

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

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

n = A("n")
i = B("i")
c = C("c")
a = D("a")
l = C("l")
d = C("d")
h = D("h")
j = D("j")
k = D("k")

n.q = d
n.w = d
n.t = i
i.y = d
i.q = n
i.t = j
c.r = i
c.p = i
a.t = k
a.w = l
a.q = n
l.r = i
l.p = i
d.r = i
d.p = i
h.t = a
h.w = l
h.q = n
j.t = h
j.w = d
j.q = n
k.t = a
k.w = c
k.q = n
assert l.r.q.w.p.txt == "i"