class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.p: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: G = None
        self.v: C = None
        self.y: B = None
        self.p: C = None
        self.z: D = None
        self.t: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: F = None
        self.txt = txt

h = A("h")
e = B("e")
c = C("c")
k = D("k")
l = E("l")
m = F("m")
j = G("j")
f = G("f")
d = B("d")

h.q = m
h.p = k
e.r = m
e.o = f
e.q = l
c.x = m
c.y = k
k.r = e
k.s = m
l.x = c
l.p = c
l.r = c
l.q = d
l.w = k
l.s = k
m.x = f
m.v = c
m.p = c
m.t = c
m.y = d
m.z = k
j.u = k
j.r = m
f.u = k
f.r = m
d.r = m
d.o = j
d.q = l
assert m.x.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.p: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.x: G = None
        self.v: C = None
        self.y: B = None
        self.p: C = None
        self.z: D = None
        self.t: C = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: F = None
        self.txt = txt

h = A("h")
e = B("e")
c = C("c")
k = D("k")
l = E("l")
m = F("m")
j = G("j")
f = G("f")
d = B("d")

h.q = m
h.p = k
e.r = m
e.o = f
e.q = l
c.x = m
c.y = k
k.r = e
k.s = m
l.x = c
l.p = c
l.r = c
l.q = d
l.w = k
l.s = k
m.x = f
m.v = c
m.p = c
m.t = c
m.y = d
m.z = k
j.u = k
j.r = m
f.u = k
f.r = m
d.r = m
d.o = j
d.q = l
assert m.x.r.x.txt == "f"