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

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

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

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

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

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

m = A("m")
l = B("l")
n = C("n")
h = D("h")
a = E("a")
k = F("k")

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

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

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

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

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

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

m = A("m")
l = B("l")
n = C("n")
h = D("h")
a = E("a")
k = F("k")

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