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

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

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

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

k = A("k")
m = B("m")
f = C("f")
l = D("l")
c = B("c")
g = D("g")
h = C("h")
j = C("j")
n = A("n")
b = D("b")

k.x = n
k.v = n
k.r = g
k.q = g
m.s = j
f.z = h
f.p = j
f.o = k
l.z = m
c.s = h
g.z = m
h.z = f
h.p = j
h.o = k
j.z = f
j.p = f
j.o = n
n.x = k
n.v = k
n.r = l
n.q = g
b.z = c
assert n.q.z.s.p.z.z.z.z.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: D = None
        self.q: D = None
        self.v: A = None
        self.txt = txt

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

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

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

k = A("k")
m = B("m")
f = C("f")
l = D("l")
c = B("c")
g = D("g")
h = C("h")
j = C("j")
n = A("n")
b = D("b")

k.x = n
k.v = n
k.r = g
k.q = g
m.s = j
f.z = h
f.p = j
f.o = k
l.z = m
c.s = h
g.z = m
h.z = f
h.p = j
h.o = k
j.z = f
j.p = f
j.o = n
n.x = k
n.v = k
n.r = l
n.q = g
b.z = c
assert n.q.z.s.p.z.z.z.z.p.txt == "j"