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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.z: F = None
        self.y: F = None
        self.s: C = None
        self.p: A = None
        self.txt = txt

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

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.t: E = None
        self.z: F = None
        self.y: F = None
        self.s: C = None
        self.p: A = None
        self.txt = txt

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

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

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

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