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

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

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

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

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

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

m = A("m")
d = B("d")
e = C("e")
h = D("h")
n = E("n")
f = F("f")

m.u = n
m.x = e
m.r = e
d.y = n
d.r = h
e.r = m
e.y = m
e.p = d
e.t = h
e.v = n
e.q = f
h.r = m
h.t = m
n.v = f
n.z = e
f.v = n
f.y = h
assert h.t.u.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.x: C = None
        self.r: C = None
        self.txt = txt

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

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

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

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

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

m = A("m")
d = B("d")
e = C("e")
h = D("h")
n = E("n")
f = F("f")

m.u = n
m.x = e
m.r = e
d.y = n
d.r = h
e.r = m
e.y = m
e.p = d
e.t = h
e.v = n
e.q = f
h.r = m
h.t = m
n.v = f
n.z = e
f.v = n
f.y = h
assert h.t.u.v.y.txt == "h"