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

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

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

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

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

j.q = d
j.s = d
d.v = i
n.p = d
n.u = i
i.u = j
i.o = d
i.w = d
assert d.v.w.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: B = None
        self.txt = txt

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

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

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

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

j.q = d
j.s = d
d.v = i
n.p = d
n.u = i
i.u = j
i.o = d
i.w = d
assert d.v.w.v.o.txt == "d"