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

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: G = None
        self.x: D = None
        self.r: D = None
        self.w: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.q: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: H = None
        self.u: E = None
        self.r: B = None
        self.q: E = None
        self.v: H = None
        self.txt = txt

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

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

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

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

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

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

a.s = k
g.v = d
g.x = d
g.r = d
g.o = m
g.w = k
k.s = f
k.q = f
d.s = g
d.r = g
d.x = n
d.v = n
d.u = f
d.q = f
f.q = d
e.s = g
e.x = g
m.x = f
m.s = d
n.x = a
i.x = m
assert k.s.q.v.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: G = None
        self.x: D = None
        self.r: D = None
        self.w: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.q: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.s: B = None
        self.x: H = None
        self.u: E = None
        self.r: B = None
        self.q: E = None
        self.v: H = None
        self.txt = txt

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

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

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

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

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

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

a.s = k
g.v = d
g.x = d
g.r = d
g.o = m
g.w = k
k.s = f
k.q = f
d.s = g
d.r = g
d.x = n
d.v = n
d.u = f
d.q = f
f.q = d
e.s = g
e.x = g
m.x = f
m.s = d
n.x = a
i.x = m
assert k.s.q.v.x.s.txt == "k"