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

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

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

class D:
    def __init__(self, txt: str):
        self.v: F = None
        self.s: B = None
        self.x: F = None
        self.u: E = None
        self.txt = txt

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

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.v: F = None
        self.s: B = None
        self.x: F = None
        self.u: E = None
        self.txt = txt

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

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

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

j.t = h
l.t = j
f.r = h
f.q = h
f.x = j
m.v = h
m.x = h
m.s = a
m.u = n
n.u = j
n.p = j
n.s = l
n.w = m
h.q = j
a.t = j
assert m.s.t.t.q.t.q.t.txt == "h"