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

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

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

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

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

i.s = e
i.u = e
i.q = l
m.q = d
m.v = l
d.v = i
e.o = n
e.t = n
j.s = n
j.u = n
j.q = m
n.o = e
n.t = e
l.q = d
l.v = m
assert n.o.t.t.t.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: D = None
        self.q: B = None
        self.txt = txt

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

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

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

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

i.s = e
i.u = e
i.q = l
m.q = d
m.v = l
d.v = i
e.o = n
e.t = n
j.s = n
j.u = n
j.q = m
n.o = e
n.t = e
l.q = d
l.v = m
assert n.o.t.t.t.o.o.txt == "n"