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

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

a = A("a")
f = B("f")
n = C("n")
g = D("g")
l = E("l")
i = F("i")
h = G("h")
k = H("k")
m = A("m")

a.s = i
a.r = i
a.t = l
a.q = m
f.s = i
f.x = h
n.q = m
n.u = l
n.r = l
g.p = n
l.r = n
l.o = g
i.z = l
h.s = l
k.y = i
k.x = h
m.s = i
m.r = i
m.t = l
m.q = a
assert g.p.q.q.t.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.t: E = None
        self.q: A = None
        self.r: F = None
        self.txt = txt

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

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

a = A("a")
f = B("f")
n = C("n")
g = D("g")
l = E("l")
i = F("i")
h = G("h")
k = H("k")
m = A("m")

a.s = i
a.r = i
a.t = l
a.q = m
f.s = i
f.x = h
n.q = m
n.u = l
n.r = l
g.p = n
l.r = n
l.o = g
i.z = l
h.s = l
k.y = i
k.x = h
m.s = i
m.r = i
m.t = l
m.q = a
assert g.p.q.q.t.r.q.txt == "m"