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

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.w: F = None
        self.txt = txt

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

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

h.q = i
h.r = i
h.o = i
h.z = m
j.q = m
j.x = h
d.z = j
d.y = h
g.x = d
g.q = i
g.u = m
g.p = h
m.z = j
m.y = j
m.w = i
i.u = h
i.y = j
assert h.z.y.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.r: F = None
        self.z: E = None
        self.o: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.z: B = None
        self.y: B = None
        self.w: F = None
        self.txt = txt

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

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

h.q = i
h.r = i
h.o = i
h.z = m
j.q = m
j.x = h
d.z = j
d.y = h
g.x = d
g.q = i
g.u = m
g.p = h
m.z = j
m.y = j
m.w = i
i.u = h
i.y = j
assert h.z.y.x.z.txt == "m"