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

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

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

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

d = A("d")
l = B("l")
h = C("h")
j = D("j")
f = D("f")
g = A("g")
e = A("e")
n = C("n")

d.s = e
d.u = l
l.v = n
h.v = f
h.o = e
j.y = l
j.s = f
f.y = l
f.s = j
g.s = e
g.u = l
e.s = d
e.u = l
n.v = j
n.o = d
assert l.v.v.y.v.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.u: B = None
        self.txt = txt

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

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

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

d = A("d")
l = B("l")
h = C("h")
j = D("j")
f = D("f")
g = A("g")
e = A("e")
n = C("n")

d.s = e
d.u = l
l.v = n
h.v = f
h.o = e
j.y = l
j.s = f
f.y = l
f.s = j
g.s = e
g.u = l
e.s = d
e.u = l
n.v = j
n.o = d
assert l.v.v.y.v.v.s.txt == "f"