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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

m.y = n
m.z = i
m.q = h
m.r = h
n.r = m
n.s = d
l.q = h
l.v = m
l.z = n
i.x = n
i.z = h
i.y = d
i.p = m
i.u = m
h.v = i
d.p = h
assert l.v.r.v.z.v.z.txt == "h"