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

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

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

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

l = A("l")
d = B("d")
n = C("n")
f = D("f")
m = D("m")
i = B("i")

l.s = f
l.t = f
d.y = n
d.s = l
d.w = m
n.u = f
n.o = f
n.s = l
n.w = l
f.y = m
f.o = d
f.t = d
f.q = d
m.y = f
m.o = i
m.q = i
m.t = d
i.y = n
i.s = l
i.w = f
assert d.s.t.o.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.t: D = None
        self.txt = txt

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

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

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

l = A("l")
d = B("d")
n = C("n")
f = D("f")
m = D("m")
i = B("i")

l.s = f
l.t = f
d.y = n
d.s = l
d.w = m
n.u = f
n.o = f
n.s = l
n.w = l
f.y = m
f.o = d
f.t = d
f.q = d
m.y = f
m.o = i
m.q = i
m.t = d
i.y = n
i.s = l
i.w = f
assert d.s.t.o.s.t.txt == "f"