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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: F = None
        self.s: E = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: B = None
        self.q: G = None
        self.txt = txt

m = A("m")
d = B("d")
a = C("a")
h = D("h")
g = E("g")
f = F("f")
j = G("j")
l = H("l")
b = B("b")

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

class B:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: F = None
        self.s: E = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

class H:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: B = None
        self.q: G = None
        self.txt = txt

m = A("m")
d = B("d")
a = C("a")
h = D("h")
g = E("g")
f = F("f")
j = G("j")
l = H("l")
b = B("b")

m.v = j
d.t = h
d.u = f
d.s = g
d.r = g
a.v = h
a.u = h
a.t = j
a.z = d
h.z = j
h.w = l
h.v = l
h.x = a
h.s = a
g.x = j
g.w = a
f.u = b
j.u = h
j.x = b
j.p = f
l.y = h
l.p = b
l.q = j
b.t = h
b.u = f
b.s = g
b.r = g
assert f.u.t.z.p.u.t.v.p.r.txt == "g"