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

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

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

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

h = A("h")
n = B("n")
l = C("l")
g = D("g")
f = A("f")
c = B("c")
k = D("k")
a = C("a")
d = A("d")

h.u = k
h.r = a
h.y = g
n.v = c
n.s = c
l.q = a
g.s = k
f.u = k
f.y = k
f.r = a
c.v = n
c.s = n
k.s = g
a.q = l
d.u = g
d.r = l
d.y = k
assert h.y.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.r: C = None
        self.y: D = None
        self.txt = txt

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

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

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

h = A("h")
n = B("n")
l = C("l")
g = D("g")
f = A("f")
c = B("c")
k = D("k")
a = C("a")
d = A("d")

h.u = k
h.r = a
h.y = g
n.v = c
n.s = c
l.q = a
g.s = k
f.u = k
f.y = k
f.r = a
c.v = n
c.s = n
k.s = g
a.q = l
d.u = g
d.r = l
d.y = k
assert h.y.s.s.s.s.s.s.txt == "g"