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

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: E = None
        self.r: E = None
        self.v: E = None
        self.o: E = None
        self.x: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: D = None
        self.w: E = None
        self.txt = txt

a = A("a")
b = B("b")
m = C("m")
h = D("h")
c = E("c")
d = F("d")
n = D("n")
l = B("l")

a.w = m
a.r = m
b.x = h
b.u = h
b.y = a
b.z = c
m.t = b
m.z = d
m.y = d
h.q = m
h.z = c
h.r = c
h.v = c
h.o = c
h.x = a
c.x = d
c.t = h
d.r = a
d.x = n
d.w = c
n.q = m
n.z = c
n.r = c
n.v = c
n.o = c
n.x = a
l.x = n
l.u = n
l.y = a
l.z = c
assert m.z.w.x.x.r.t.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.r: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: C = None
        self.z: E = None
        self.r: E = None
        self.v: E = None
        self.o: E = None
        self.x: A = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.r: A = None
        self.x: D = None
        self.w: E = None
        self.txt = txt

a = A("a")
b = B("b")
m = C("m")
h = D("h")
c = E("c")
d = F("d")
n = D("n")
l = B("l")

a.w = m
a.r = m
b.x = h
b.u = h
b.y = a
b.z = c
m.t = b
m.z = d
m.y = d
h.q = m
h.z = c
h.r = c
h.v = c
h.o = c
h.x = a
c.x = d
c.t = h
d.r = a
d.x = n
d.w = c
n.q = m
n.z = c
n.r = c
n.v = c
n.o = c
n.x = a
l.x = n
l.u = n
l.y = a
l.z = c
assert m.z.w.x.x.r.t.x.txt == "a"