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

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

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

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

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

j.s = d
c.o = d
c.w = f
f.r = d
f.s = d
f.z = c
n.s = j
n.q = d
n.w = d
n.t = d
b.s = j
b.q = d
b.t = d
b.w = f
i.s = f
d.r = f
d.s = f
d.z = c
assert i.s.z.w.r.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.txt = txt

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

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

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

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

j.s = d
c.o = d
c.w = f
f.r = d
f.s = d
f.z = c
n.s = j
n.q = d
n.w = d
n.t = d
b.s = j
b.q = d
b.t = d
b.w = f
i.s = f
d.r = f
d.s = f
d.z = c
assert i.s.z.w.r.s.r.txt == "d"