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

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

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

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

d = A("d")
i = B("i")
c = C("c")
n = D("n")
a = D("a")
j = B("j")
f = D("f")
g = D("g")

d.t = j
i.w = d
i.o = d
i.t = n
c.x = i
c.y = n
n.w = c
n.s = a
a.w = c
a.s = f
j.w = d
j.o = d
j.t = f
f.w = c
f.s = g
g.w = c
g.s = a
assert n.w.y.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

d = A("d")
i = B("i")
c = C("c")
n = D("n")
a = D("a")
j = B("j")
f = D("f")
g = D("g")

d.t = j
i.w = d
i.o = d
i.t = n
c.x = i
c.y = n
n.w = c
n.s = a
a.w = c
a.s = f
j.w = d
j.o = d
j.t = f
f.w = c
f.s = g
g.w = c
g.s = a
assert n.w.y.s.s.txt == "f"