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

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

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

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

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

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

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

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

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

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

n.q = b
n.x = d
n.o = i
n.s = i
i.t = e
m.q = n
j.t = b
j.y = b
j.x = m
d.t = b
d.y = b
d.x = m
e.q = b
e.x = d
e.o = i
e.s = i
b.q = e
assert i.t.x.x.q.o.t.txt == "e"