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

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

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

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

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

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

h = A("h")
f = B("f")
g = C("g")
b = D("b")
n = E("n")
m = F("m")
j = E("j")

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

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

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

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

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

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

h = A("h")
f = B("f")
g = C("g")
b = D("b")
n = E("n")
m = F("m")
j = E("j")

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