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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: I = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: F = None
        self.t: E = None
        self.s: F = None
        self.txt = txt

class I:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: A = None
        self.q: I = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: F = None
        self.t: E = None
        self.s: F = None
        self.txt = txt

class I:
    def __init__(self, txt: str):
        self.q: F = None
        self.txt = txt

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

f.o = m
a.p = m
a.z = b
a.o = b
a.t = l
b.z = f
b.y = f
m.y = n
n.p = f
n.q = c
g.u = l
g.s = h
g.z = m
l.w = g
l.s = h
l.t = a
h.z = m
h.v = g
h.s = g
h.t = n
c.q = g
assert m.y.q.q.s.s.z.y.txt == "n"