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

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: A = None
        self.u: C = None
        self.txt = txt

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

d.p = i
d.z = i
d.x = n
n.q = i
n.w = c
k.s = i
k.v = d
k.u = c
j.s = d
j.v = d
j.u = k
c.s = d
c.v = i
c.u = j
a.s = d
a.v = i
a.u = j
i.p = d
i.z = d
i.x = n
assert d.x.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.z: A = None
        self.x: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: A = None
        self.v: A = None
        self.u: C = None
        self.txt = txt

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

d.p = i
d.z = i
d.x = n
n.q = i
n.w = c
k.s = i
k.v = d
k.u = c
j.s = d
j.v = d
j.u = k
c.s = d
c.v = i
c.u = j
a.s = d
a.v = i
a.u = j
i.p = d
i.z = d
i.x = n
assert d.x.q.p.txt == "d"