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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: B = None
        self.v: C = None
        self.w: B = None
        self.q: A = None
        self.txt = txt

m = A("m")
h = B("h")
i = C("i")
l = D("l")
d = E("d")
g = F("g")
a = A("a")

m.u = g
h.o = i
h.x = l
h.y = l
h.u = m
h.q = g
h.t = g
i.s = g
l.r = i
d.q = g
g.y = i
g.v = i
g.z = h
g.w = h
g.q = m
a.u = g
assert h.q.w.q.q.u.z.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: B = None
        self.v: C = None
        self.w: B = None
        self.q: A = None
        self.txt = txt

m = A("m")
h = B("h")
i = C("i")
l = D("l")
d = E("d")
g = F("g")
a = A("a")

m.u = g
h.o = i
h.x = l
h.y = l
h.u = m
h.q = g
h.t = g
i.s = g
l.r = i
d.q = g
g.y = i
g.v = i
g.z = h
g.w = h
g.q = m
a.u = g
assert h.q.w.q.q.u.z.q.txt == "g"