class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.z: H = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

class H:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: G = None
        self.x: C = None
        self.p: D = None
        self.txt = txt

f = A("f")
g = B("g")
d = C("d")
k = D("k")
i = E("i")
j = F("j")
l = G("l")
h = H("h")

f.r = l
f.z = h
f.q = i
g.t = j
d.z = f
k.s = f
i.q = k
i.u = k
i.v = k
j.w = h
j.s = f
l.w = k
h.s = f
h.z = l
h.x = d
h.p = k
assert k.s.q.v.s.r.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: G = None
        self.z: H = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: F = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

class H:
    def __init__(self, txt: str):
        self.s: A = None
        self.z: G = None
        self.x: C = None
        self.p: D = None
        self.txt = txt

f = A("f")
g = B("g")
d = C("d")
k = D("k")
i = E("i")
j = F("j")
l = G("l")
h = H("h")

f.r = l
f.z = h
f.q = i
g.t = j
d.z = f
k.s = f
i.q = k
i.u = k
i.v = k
j.w = h
j.s = f
l.w = k
h.s = f
h.z = l
h.x = d
h.p = k
assert k.s.q.v.s.r.w.s.q.txt == "i"