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

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.t: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: B = None
        self.q: B = None
        self.t: F = None
        self.s: C = None
        self.v: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: E = None
        self.y: E = None
        self.v: A = None
        self.z: C = None
        self.s: E = None
        self.txt = txt

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

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

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

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.t: F = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: B = None
        self.q: B = None
        self.t: F = None
        self.s: C = None
        self.v: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: E = None
        self.y: E = None
        self.v: A = None
        self.z: C = None
        self.s: E = None
        self.txt = txt

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

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