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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.q: E = None
        self.txt = txt

b = A("b")
n = B("n")
h = C("h")
j = D("j")
d = E("d")
m = E("m")

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

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

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

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

class E:
    def __init__(self, txt: str):
        self.t: B = None
        self.x: B = None
        self.q: E = None
        self.txt = txt

b = A("b")
n = B("n")
h = C("h")
j = D("j")
d = E("d")
m = E("m")

b.t = h
b.r = h
b.x = n
n.s = h
n.w = h
n.v = b
n.q = b
h.r = n
j.x = m
j.y = b
j.o = b
d.t = n
d.x = n
d.q = m
m.t = n
m.x = n
m.q = d
assert m.q.x.w.r.w.r.txt == "n"