class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: F = None
        self.z: D = None
        self.o: G = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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