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

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

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

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

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

d = A("d")
k = B("k")
g = C("g")
j = D("j")
h = E("h")
m = D("m")
e = B("e")
b = A("b")
c = B("c")

d.x = b
d.q = j
k.w = h
k.s = m
g.p = b
j.y = c
j.u = m
h.o = g
h.y = b
m.y = k
m.u = j
e.w = h
e.s = j
b.x = d
b.q = j
c.w = h
c.s = m
assert j.y.s.u.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.q: D = None
        self.txt = txt

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

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

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

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

d = A("d")
k = B("k")
g = C("g")
j = D("j")
h = E("h")
m = D("m")
e = B("e")
b = A("b")
c = B("c")

d.x = b
d.q = j
k.w = h
k.s = m
g.p = b
j.y = c
j.u = m
h.o = g
h.y = b
m.y = k
m.u = j
e.w = h
e.s = j
b.x = d
b.q = j
c.w = h
c.s = m
assert j.y.s.u.txt == "j"