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

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

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

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

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

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

e = A("e")
m = B("m")
n = C("n")
h = D("h")
f = E("f")
j = F("j")
i = E("i")
b = F("b")
g = E("g")

e.r = h
m.w = n
m.t = n
m.z = h
n.z = h
n.u = b
n.x = e
h.p = m
h.v = m
h.x = n
h.y = n
f.s = m
f.y = h
j.y = m
i.s = m
i.y = h
b.y = m
g.s = m
g.y = h
assert m.t.z.p.w.u.y.z.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

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

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

e = A("e")
m = B("m")
n = C("n")
h = D("h")
f = E("f")
j = F("j")
i = E("i")
b = F("b")
g = E("g")

e.r = h
m.w = n
m.t = n
m.z = h
n.z = h
n.u = b
n.x = e
h.p = m
h.v = m
h.x = n
h.y = n
f.s = m
f.y = h
j.y = m
i.s = m
i.y = h
b.y = m
g.s = m
g.y = h
assert m.t.z.p.w.u.y.z.v.z.txt == "h"