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

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: D = None
        self.u: D = None
        self.s: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: E = None
        self.z: B = None
        self.r: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

l = A("l")
f = B("f")
d = C("d")
a = D("a")
m = E("m")
i = F("i")
h = D("h")
k = E("k")

l.z = h
l.p = a
l.r = f
l.u = i
l.s = i
f.x = a
f.u = d
d.v = f
d.q = a
d.u = h
d.s = m
a.u = l
m.s = k
m.z = f
m.r = d
i.o = f
h.u = l
k.s = m
k.z = f
k.r = d
assert m.r.s.s.s.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: D = None
        self.r: B = None
        self.u: F = None
        self.s: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.q: D = None
        self.u: D = None
        self.s: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: E = None
        self.z: B = None
        self.r: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

l = A("l")
f = B("f")
d = C("d")
a = D("a")
m = E("m")
i = F("i")
h = D("h")
k = E("k")

l.z = h
l.p = a
l.r = f
l.u = i
l.s = i
f.x = a
f.u = d
d.v = f
d.q = a
d.u = h
d.s = m
a.u = l
m.s = k
m.z = f
m.r = d
i.o = f
h.u = l
k.s = m
k.z = f
k.r = d
assert m.r.s.s.s.z.txt == "f"