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

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

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

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

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

h.s = g
f.s = e
f.q = k
f.o = l
f.u = m
m.u = f
m.v = f
m.p = k
g.y = m
g.v = f
g.t = k
i.u = f
i.v = f
i.p = k
e.y = m
e.v = f
e.t = f
l.s = e
k.s = e
k.q = f
k.o = l
k.u = i
assert f.q.q.q.q.u.p.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

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

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

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

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

h.s = g
f.s = e
f.q = k
f.o = l
f.u = m
m.u = f
m.v = f
m.p = k
g.y = m
g.v = f
g.t = k
i.u = f
i.v = f
i.p = k
e.y = m
e.v = f
e.t = f
l.s = e
k.s = e
k.q = f
k.o = l
k.u = i
assert f.q.q.q.q.u.p.u.v.txt == "f"