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

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

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

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

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

h = A("h")
a = B("a")
j = C("j")
m = D("m")
g = E("g")
b = C("b")
e = D("e")

h.r = a
a.z = j
a.x = j
j.o = b
j.y = g
m.o = a
m.p = e
m.u = g
m.y = b
g.u = h
g.s = h
g.x = m
g.t = b
g.v = a
b.o = j
b.y = g
e.o = a
e.p = m
e.u = g
e.y = j
assert b.y.s.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

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

h = A("h")
a = B("a")
j = C("j")
m = D("m")
g = E("g")
b = C("b")
e = D("e")

h.r = a
a.z = j
a.x = j
j.o = b
j.y = g
m.o = a
m.p = e
m.u = g
m.y = b
g.u = h
g.s = h
g.x = m
g.t = b
g.v = a
b.o = j
b.y = g
e.o = a
e.p = m
e.u = g
e.y = j
assert b.y.s.r.x.txt == "j"