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

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

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

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

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

l.o = i
l.y = b
a.p = i
a.w = j
i.y = j
i.w = n
d.v = n
d.r = n
n.p = i
n.w = j
b.v = a
b.r = n
j.o = i
j.y = d
assert d.v.w.y.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: D = None
        self.txt = txt

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

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

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

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

l.o = i
l.y = b
a.p = i
a.w = j
i.y = j
i.w = n
d.v = n
d.r = n
n.p = i
n.w = j
b.v = a
b.r = n
j.o = i
j.y = d
assert d.v.w.y.r.w.txt == "j"