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

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

c = A("c")
k = B("k")
i = C("i")
a = D("a")
j = A("j")
m = A("m")
b = B("b")
n = D("n")
e = D("e")

c.t = m
c.p = i
c.r = n
k.q = b
k.r = b
i.p = j
a.z = i
j.t = c
j.p = i
j.r = n
m.t = c
m.p = i
m.r = e
b.q = k
b.r = k
n.z = i
e.z = i
assert e.z.p.t.p.p.r.z.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.p: C = None
        self.r: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

c = A("c")
k = B("k")
i = C("i")
a = D("a")
j = A("j")
m = A("m")
b = B("b")
n = D("n")
e = D("e")

c.t = m
c.p = i
c.r = n
k.q = b
k.r = b
i.p = j
a.z = i
j.t = c
j.p = i
j.r = n
m.t = c
m.p = i
m.r = e
b.q = k
b.r = k
n.z = i
e.z = i
assert e.z.p.t.p.p.r.z.p.p.txt == "i"