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

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

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

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

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

k.q = a
k.z = j
k.p = d
k.r = c
j.z = c
j.v = k
j.x = k
c.p = b
c.y = k
c.t = k
c.s = a
d.q = k
d.z = n
d.v = n
d.x = a
n.q = k
n.z = d
n.v = d
n.x = a
a.z = c
a.v = k
a.x = k
b.p = c
b.y = k
b.t = k
b.s = j
assert n.x.x.p.q.q.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.z: B = None
        self.p: D = None
        self.r: C = None
        self.txt = txt

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

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

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

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

k.q = a
k.z = j
k.p = d
k.r = c
j.z = c
j.v = k
j.x = k
c.p = b
c.y = k
c.t = k
c.s = a
d.q = k
d.z = n
d.v = n
d.x = a
n.q = k
n.z = d
n.v = d
n.x = a
a.z = c
a.v = k
a.x = k
b.p = c
b.y = k
b.t = k
b.s = j
assert n.x.x.p.q.q.z.t.txt == "k"