class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: G = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: H = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: H = None
        self.p: E = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.z: G = None
        self.x: F = None
        self.o: A = None
        self.s: A = None
        self.r: B = None
        self.txt = txt

a = A("a")
j = B("j")
n = C("n")
k = D("k")
c = E("c")
m = F("m")
e = G("e")
d = H("d")
h = E("h")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: H = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: H = None
        self.p: E = None
        self.txt = txt

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

class H:
    def __init__(self, txt: str):
        self.z: G = None
        self.x: F = None
        self.o: A = None
        self.s: A = None
        self.r: B = None
        self.txt = txt

a = A("a")
j = B("j")
n = C("n")
k = D("k")
c = E("c")
m = F("m")
e = G("e")
d = H("d")
h = E("h")

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