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

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

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

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

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

j.o = n
j.y = c
l.r = d
d.y = n
e.w = l
n.o = i
n.y = c
c.r = d
i.o = n
i.y = l
assert e.w.r.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: B = None
        self.txt = txt

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

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

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

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

j.o = n
j.y = c
l.r = d
d.y = n
e.w = l
n.o = i
n.y = c
c.r = d
i.o = n
i.y = l
assert e.w.r.y.txt == "n"