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

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

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

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

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

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

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

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

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

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

n.o = a
g.w = i
i.x = g
i.v = g
i.r = g
j.v = i
j.o = c
l.v = i
l.o = n
c.o = g
a.w = i
e.v = i
e.o = c
assert a.w.r.w.txt == "i"