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

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

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

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

e = A("e")
h = B("h")
j = C("j")
b = D("b")
d = A("d")
a = C("a")

e.y = h
e.q = d
e.s = d
h.u = b
h.t = b
h.o = j
j.x = a
j.s = b
j.t = h
b.u = a
b.w = e
d.y = h
d.q = e
d.s = e
a.x = j
a.s = b
a.t = h
assert b.w.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: A = None
        self.s: A = None
        self.txt = txt

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

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

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

e = A("e")
h = B("h")
j = C("j")
b = D("b")
d = A("d")
a = C("a")

e.y = h
e.q = d
e.s = d
h.u = b
h.t = b
h.o = j
j.x = a
j.s = b
j.t = h
b.u = a
b.w = e
d.y = h
d.q = e
d.s = e
a.x = j
a.s = b
a.t = h
assert b.w.s.q.txt == "e"