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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: C = None
        self.txt = txt

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

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

n.r = h
n.s = l
g.r = f
f.t = h
f.w = e
l.o = n
l.t = k
e.t = h
e.w = f
k.r = f
a.o = h
a.t = k
h.r = n
h.s = l
j.o = h
j.t = k
assert f.w.t.s.t.r.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.s: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.w: C = None
        self.txt = txt

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

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

n.r = h
n.s = l
g.r = f
f.t = h
f.w = e
l.o = n
l.t = k
e.t = h
e.w = f
k.r = f
a.o = h
a.t = k
h.r = n
h.s = l
j.o = h
j.t = k
assert f.w.t.s.t.r.w.w.txt == "f"