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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.q: D = None
        self.r: F = None
        self.v: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: F = None
        self.t: I = None
        self.v: C = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: G = None
        self.y: F = None
        self.z: C = None
        self.u: B = None
        self.txt = txt

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

a = A("a")
b = B("b")
j = C("j")
k = D("k")
f = E("f")
g = F("g")
c = G("c")
m = H("m")
d = I("d")

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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.q: D = None
        self.r: F = None
        self.v: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.p: F = None
        self.t: I = None
        self.v: C = None
        self.txt = txt

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

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

class H:
    def __init__(self, txt: str):
        self.r: A = None
        self.p: G = None
        self.y: F = None
        self.z: C = None
        self.u: B = None
        self.txt = txt

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

a = A("a")
b = B("b")
j = C("j")
k = D("k")
f = E("f")
g = F("g")
c = G("c")
m = H("m")
d = I("d")

a.q = c
b.p = m
j.p = f
j.v = f
j.q = k
j.r = g
k.o = a
f.z = b
f.p = g
f.t = d
f.v = j
g.u = m
c.q = d
m.r = a
m.p = c
m.y = g
m.z = j
m.u = b
d.v = j
d.s = b
d.o = a
d.x = k
d.y = c
assert j.p.v.q.o.q.q.s.p.txt == "m"