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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: H = None
        self.v: G = None
        self.x: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

f = A("f")
k = B("k")
i = C("i")
d = D("d")
l = E("l")
h = F("h")
g = G("g")
e = H("e")

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

class B:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: H = None
        self.v: G = None
        self.x: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.w: D = None
        self.txt = txt

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

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

f = A("f")
k = B("k")
i = C("i")
d = D("d")
l = E("l")
h = F("h")
g = G("g")
e = H("e")

f.x = h
k.o = d
k.x = d
k.p = e
k.v = g
i.y = e
d.q = f
d.p = f
d.u = l
d.r = h
l.p = k
l.w = i
h.w = d
g.t = e
e.x = k
assert h.w.u.w.txt == "i"