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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: E = None
        self.r: C = None
        self.q: C = None
        self.txt = txt

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

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

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

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

h = A("h")
l = B("l")
b = C("b")
n = D("n")
m = E("m")
i = F("i")

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

class B:
    def __init__(self, txt: str):
        self.s: A = None
        self.p: E = None
        self.r: C = None
        self.q: C = None
        self.txt = txt

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

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

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

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

h = A("h")
l = B("l")
b = C("b")
n = D("n")
m = E("m")
i = F("i")

h.q = m
h.x = n
h.u = n
l.s = h
l.p = m
l.r = b
l.q = b
b.u = m
b.s = m
n.t = i
n.z = m
m.t = n
m.p = b
i.u = b
i.o = n
i.q = n
i.t = m
assert n.t.t.p.u.txt == "m"