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

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

class C:
    def __init__(self, txt: str):
        self.r: G = None
        self.w: H = None
        self.o: G = None
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.r: B = None
        self.w: F = None
        self.u: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.z: B = None
        self.q: H = None
        self.r: C = None
        self.t: B = None
        self.y: H = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

d.z = h
d.r = l
f.p = h
f.r = a
f.y = l
f.q = n
g.r = a
g.o = a
g.w = n
g.q = h
h.o = m
h.r = f
h.w = l
h.u = g
m.p = l
m.z = f
m.t = f
m.q = n
m.y = n
m.r = g
l.t = d
l.x = d
a.y = f
a.u = d
a.o = h
n.y = g
assert a.o.w.x.z.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.r: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: G = None
        self.w: H = None
        self.o: G = None
        self.q: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: E = None
        self.r: B = None
        self.w: F = None
        self.u: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: F = None
        self.z: B = None
        self.q: H = None
        self.r: C = None
        self.t: B = None
        self.y: H = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

d.z = h
d.r = l
f.p = h
f.r = a
f.y = l
f.q = n
g.r = a
g.o = a
g.w = n
g.q = h
h.o = m
h.r = f
h.w = l
h.u = g
m.p = l
m.z = f
m.t = f
m.q = n
m.y = n
m.r = g
l.t = d
l.x = d
a.y = f
a.u = d
a.o = h
n.y = g
assert a.o.w.x.z.u.o.u.txt == "d"