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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: A = None
        self.t: A = None
        self.p: G = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: H = None
        self.txt = txt

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

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

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

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

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

d = A("d")
b = B("b")
h = C("h")
i = D("i")
g = E("g")
f = F("f")
c = G("c")
n = H("n")
k = I("k")

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

class B:
    def __init__(self, txt: str):
        self.o: E = None
        self.u: A = None
        self.t: A = None
        self.p: G = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.t: H = None
        self.txt = txt

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

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

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

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

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

d = A("d")
b = B("b")
h = C("h")
i = D("i")
g = E("g")
f = F("f")
c = G("c")
n = H("n")
k = I("k")

d.x = h
b.o = g
b.u = d
b.t = d
b.p = c
h.t = n
i.t = n
g.y = d
g.s = f
g.t = f
g.r = b
f.q = g
f.r = g
f.v = c
f.t = i
f.z = h
c.y = k
c.s = k
n.s = f
n.r = i
k.p = d
k.y = d
k.z = c
assert h.t.r.t.s.txt == "f"