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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: E = None
        self.v: D = None
        self.q: D = None
        self.y: D = None
        self.z: C = None
        self.p: B = None
        self.txt = txt

m = A("m")
b = B("b")
d = C("d")
f = D("f")
g = E("g")
i = F("i")
h = G("h")

m.p = i
m.x = i
b.q = i
d.s = m
d.y = m
f.r = d
f.q = b
g.y = b
g.u = f
g.q = h
i.s = d
h.s = d
h.z = d
h.r = g
h.v = f
h.q = f
h.y = f
h.p = b
assert h.y.r.s.p.s.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.x: F = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: E = None
        self.v: D = None
        self.q: D = None
        self.y: D = None
        self.z: C = None
        self.p: B = None
        self.txt = txt

m = A("m")
b = B("b")
d = C("d")
f = D("f")
g = E("g")
i = F("i")
h = G("h")

m.p = i
m.x = i
b.q = i
d.s = m
d.y = m
f.r = d
f.q = b
g.y = b
g.u = f
g.q = h
i.s = d
h.s = d
h.z = d
h.r = g
h.v = f
h.q = f
h.y = f
h.p = b
assert h.y.r.s.p.s.s.p.txt == "i"