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

class B:
    def __init__(self, txt: str):
        self.w: G = None
        self.p: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: B = None
        self.u: G = None
        self.y: C = None
        self.o: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: D = None
        self.u: H = None
        self.p: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: F = None
        self.o: E = None
        self.txt = txt

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

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

g.y = k
g.x = f
f.w = k
f.p = d
i.s = m
i.r = a
n.t = d
n.x = f
n.o = f
n.u = k
n.y = i
d.o = f
d.z = n
d.u = m
d.p = i
a.x = n
a.o = n
a.y = i
a.v = f
k.u = g
k.y = a
k.o = d
m.w = f
m.y = d
assert f.w.u.x.w.y.v.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: G = None
        self.x: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.w: G = None
        self.p: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.x: B = None
        self.u: G = None
        self.y: C = None
        self.o: B = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: B = None
        self.z: D = None
        self.u: H = None
        self.p: C = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.u: A = None
        self.y: F = None
        self.o: E = None
        self.txt = txt

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

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

g.y = k
g.x = f
f.w = k
f.p = d
i.s = m
i.r = a
n.t = d
n.x = f
n.o = f
n.u = k
n.y = i
d.o = f
d.z = n
d.u = m
d.p = i
a.x = n
a.o = n
a.y = i
a.v = f
k.u = g
k.y = a
k.o = d
m.w = f
m.y = d
assert f.w.u.x.w.y.v.w.u.txt == "g"