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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.w: H = None
        self.y: E = None
        self.x: F = None
        self.v: D = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: E = None
        self.v: H = None
        self.u: A = None
        self.txt = txt

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

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

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

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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.w: H = None
        self.y: E = None
        self.x: F = None
        self.v: D = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: E = None
        self.v: H = None
        self.u: A = None
        self.txt = txt

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

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

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

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