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

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

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

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

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

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

k = A("k")
l = B("l")
n = C("n")
g = D("g")
f = E("f")
h = F("h")
m = B("m")

k.r = m
l.q = f
l.y = k
l.z = k
l.s = m
n.r = k
g.q = f
g.u = f
f.p = k
f.s = n
f.v = g
h.y = f
h.u = f
h.x = k
h.w = g
h.s = n
m.q = f
m.y = k
m.z = k
m.s = l
assert l.q.s.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

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

k = A("k")
l = B("l")
n = C("n")
g = D("g")
f = E("f")
h = F("h")
m = B("m")

k.r = m
l.q = f
l.y = k
l.z = k
l.s = m
n.r = k
g.q = f
g.u = f
f.p = k
f.s = n
f.v = g
h.y = f
h.u = f
h.x = k
h.w = g
h.s = n
m.q = f
m.y = k
m.z = k
m.s = l
assert l.q.s.r.r.q.txt == "f"