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

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

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

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

m = A("m")
g = B("g")
i = C("i")
f = D("f")
e = A("e")
j = D("j")
k = C("k")
d = B("d")
h = B("h")

m.t = g
m.p = i
m.x = d
m.v = e
g.s = h
i.q = j
i.p = m
f.w = k
f.p = k
f.y = j
e.t = d
e.x = d
e.p = k
e.v = m
j.w = i
j.y = f
j.p = k
k.q = j
k.p = m
d.s = g
h.s = d
assert h.s.s.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.p: C = None
        self.x: B = None
        self.v: A = None
        self.txt = txt

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

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

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

m = A("m")
g = B("g")
i = C("i")
f = D("f")
e = A("e")
j = D("j")
k = C("k")
d = B("d")
h = B("h")

m.t = g
m.p = i
m.x = d
m.v = e
g.s = h
i.q = j
i.p = m
f.w = k
f.p = k
f.y = j
e.t = d
e.x = d
e.p = k
e.v = m
j.w = i
j.y = f
j.p = k
k.q = j
k.p = m
d.s = g
h.s = d
assert h.s.s.s.s.s.s.s.s.s.txt == "h"