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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: C = None
        self.x: E = None
        self.y: A = None
        self.q: D = None
        self.txt = txt

h = A("h")
a = B("a")
f = C("f")
m = D("m")
n = E("n")
i = F("i")

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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.r: C = None
        self.x: E = None
        self.y: A = None
        self.q: D = None
        self.txt = txt

h = A("h")
a = B("a")
f = C("f")
m = D("m")
n = E("n")
i = F("i")

h.z = m
h.s = f
a.w = i
a.o = i
f.o = a
m.t = h
m.p = a
m.u = a
n.x = f
n.r = f
n.v = h
n.z = h
n.q = m
i.v = f
i.r = f
i.x = n
i.y = h
i.q = m
assert f.o.o.q.txt == "m"