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

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: D = None
        self.r: D = None
        self.txt = txt

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

l.y = m
l.w = f
l.t = d
j.p = m
m.v = i
d.q = f
d.u = i
d.r = i
i.q = l
i.u = d
i.r = d
a.p = m
f.y = m
f.w = l
f.t = d
assert d.u.r.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.w: A = None
        self.t: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: D = None
        self.r: D = None
        self.txt = txt

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

l.y = m
l.w = f
l.t = d
j.p = m
m.v = i
d.q = f
d.u = i
d.r = i
i.q = l
i.u = d
i.r = d
a.p = m
f.y = m
f.w = l
f.t = d
assert d.u.r.q.w.txt == "l"