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

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: F = None
        self.x: F = None
        self.s: F = None
        self.txt = txt

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

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

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

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

l.z = m
d.p = l
b.y = n
b.q = g
b.x = g
b.s = g
n.z = l
n.s = m
n.o = b
m.u = d
m.r = d
m.o = d
m.z = n
g.y = b
g.s = n
g.r = d
assert n.z.z.z.o.y.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.y: D = None
        self.q: F = None
        self.x: F = None
        self.s: F = None
        self.txt = txt

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

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

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

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

l.z = m
d.p = l
b.y = n
b.q = g
b.x = g
b.s = g
n.z = l
n.s = m
n.o = b
m.u = d
m.r = d
m.o = d
m.z = n
g.y = b
g.s = n
g.r = d
assert n.z.z.z.o.y.z.txt == "l"