class A:
    def __init__(self, txt: str):
        self.z: G = None
        self.r: G = None
        self.w: D = None
        self.t: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: A = None
        self.x: E = None
        self.y: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.x: H = None
        self.z: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: B = None
        self.t: C = None
        self.q: F = None
        self.txt = txt

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

n = A("n")
a = B("a")
b = C("b")
e = D("e")
m = E("m")
i = F("i")
d = G("d")
f = H("f")

n.z = d
n.r = d
n.w = e
n.t = i
a.t = e
b.t = e
e.p = b
e.r = n
e.y = n
e.x = m
m.y = e
m.s = e
i.x = f
i.z = e
d.p = b
d.t = b
d.v = a
d.q = i
f.p = b
f.s = d
f.w = i
assert b.t.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: G = None
        self.r: G = None
        self.w: D = None
        self.t: F = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: A = None
        self.x: E = None
        self.y: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.x: H = None
        self.z: D = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.p: C = None
        self.v: B = None
        self.t: C = None
        self.q: F = None
        self.txt = txt

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

n = A("n")
a = B("a")
b = C("b")
e = D("e")
m = E("m")
i = F("i")
d = G("d")
f = H("f")

n.z = d
n.r = d
n.w = e
n.t = i
a.t = e
b.t = e
e.p = b
e.r = n
e.y = n
e.x = m
m.y = e
m.s = e
i.x = f
i.z = e
d.p = b
d.t = b
d.v = a
d.q = i
f.p = b
f.s = d
f.w = i
assert b.t.x.s.txt == "e"