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

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

class C:
    def __init__(self, txt: str):
        self.u: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: C = None
        self.x: B = None
        self.r: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: H = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.r: G = None
        self.t: D = None
        self.v: F = None
        self.y: F = None
        self.x: A = None
        self.u: C = None
        self.o: A = None
        self.q: A = None
        self.txt = txt

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

h.u = a
c.x = k
c.o = k
c.u = g
c.r = h
c.w = f
k.u = f
g.u = h
g.r = h
g.o = k
g.x = c
b.t = k
a.o = b
a.q = d
f.q = k
f.v = d
d.r = f
d.t = g
d.v = a
d.y = a
d.x = h
d.o = h
d.q = h
d.u = k
assert k.u.q.u.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: G = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: C = None
        self.x: B = None
        self.r: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: H = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.q: C = None
        self.v: H = None
        self.txt = txt

class H:
    def __init__(self, txt: str):
        self.r: G = None
        self.t: D = None
        self.v: F = None
        self.y: F = None
        self.x: A = None
        self.u: C = None
        self.o: A = None
        self.q: A = None
        self.txt = txt

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

h.u = a
c.x = k
c.o = k
c.u = g
c.r = h
c.w = f
k.u = f
g.u = h
g.r = h
g.o = k
g.x = c
b.t = k
a.o = b
a.q = d
f.q = k
f.v = d
d.r = f
d.t = g
d.v = a
d.y = a
d.x = h
d.o = h
d.q = h
d.u = k
assert k.u.q.u.q.u.txt == "f"