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

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.y: B = None
        self.t: B = None
        self.r: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.z: D = None
        self.w: F = None
        self.s: F = None
        self.o: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: E = None
        self.u: B = None
        self.v: E = None
        self.z: A = None
        self.txt = txt

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

h.z = b
h.r = c
d.u = m
d.r = m
d.p = l
d.y = g
d.t = g
l.x = c
l.z = m
l.w = b
l.s = e
l.o = h
m.w = d
c.p = m
b.w = l
b.p = c
b.u = g
b.v = n
b.z = h
n.p = m
e.w = l
e.p = c
e.u = g
e.v = n
e.z = h
g.u = m
g.r = m
g.p = l
g.y = d
g.t = d
assert n.p.w.p.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: F = None
        self.r: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: D = None
        self.p: C = None
        self.y: B = None
        self.t: B = None
        self.r: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.x: E = None
        self.z: D = None
        self.w: F = None
        self.s: F = None
        self.o: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: E = None
        self.u: B = None
        self.v: E = None
        self.z: A = None
        self.txt = txt

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

h.z = b
h.r = c
d.u = m
d.r = m
d.p = l
d.y = g
d.t = g
l.x = c
l.z = m
l.w = b
l.s = e
l.o = h
m.w = d
c.p = m
b.w = l
b.p = c
b.u = g
b.v = n
b.z = h
n.p = m
e.w = l
e.p = c
e.u = g
e.v = n
e.z = h
g.u = m
g.r = m
g.p = l
g.y = d
g.t = d
assert n.p.w.p.z.txt == "m"