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

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: B = None
        self.q: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: D = None
        self.txt = txt

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

m = A("m")
k = B("k")
f = C("f")
h = D("h")
a = E("a")
j = F("j")

m.s = j
k.u = m
k.t = j
f.p = m
f.u = k
f.q = k
h.q = m
h.p = f
h.x = f
a.y = h
a.t = h
j.x = a
j.v = f
assert h.p.p.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.t: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: A = None
        self.u: B = None
        self.q: B = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.y: D = None
        self.t: D = None
        self.txt = txt

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

m = A("m")
k = B("k")
f = C("f")
h = D("h")
a = E("a")
j = F("j")

m.s = j
k.u = m
k.t = j
f.p = m
f.u = k
f.q = k
h.q = m
h.p = f
h.x = f
a.y = h
a.t = h
j.x = a
j.v = f
assert h.p.p.s.txt == "j"