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

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

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

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

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

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

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

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

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

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

e.r = k
n.q = j
n.w = d
c.v = e
c.s = d
c.o = k
c.w = n
j.o = l
j.y = d
d.v = e
d.s = c
d.o = k
d.w = n
l.o = j
l.y = d
k.r = e
assert k.r.r.r.txt == "e"