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

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

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

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

l = A("l")
i = B("i")
j = C("j")
h = D("h")
f = C("f")

l.q = i
l.x = h
l.u = h
l.s = j
i.u = l
i.x = j
j.y = f
j.v = l
j.w = l
h.v = i
h.p = i
f.y = j
f.v = l
f.w = l
assert f.w.u.v.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.x: D = None
        self.u: D = None
        self.s: C = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
j = C("j")
h = D("h")
f = C("f")

l.q = i
l.x = h
l.u = h
l.s = j
i.u = l
i.x = j
j.y = f
j.v = l
j.w = l
h.v = i
h.p = i
f.y = j
f.v = l
f.w = l
assert f.w.u.v.u.txt == "l"