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

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.u: E = None
        self.p: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.v: A = None
        self.x: C = None
        self.r: A = None
        self.txt = txt

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

j = A("j")
c = B("c")
l = C("l")
k = D("k")
b = E("b")
h = E("h")

j.r = h
j.q = k
c.z = b
c.u = h
c.p = j
l.x = b
l.o = b
l.u = b
l.p = j
k.y = j
k.u = j
k.v = j
k.r = j
k.x = l
b.r = l
b.s = l
b.v = c
h.r = l
h.s = l
h.v = c
assert h.v.u.s.p.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: E = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: E = None
        self.u: E = None
        self.p: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.v: A = None
        self.x: C = None
        self.r: A = None
        self.txt = txt

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

j = A("j")
c = B("c")
l = C("l")
k = D("k")
b = E("b")
h = E("h")

j.r = h
j.q = k
c.z = b
c.u = h
c.p = j
l.x = b
l.o = b
l.u = b
l.p = j
k.y = j
k.u = j
k.v = j
k.r = j
k.x = l
b.r = l
b.s = l
b.v = c
h.r = l
h.s = l
h.v = c
assert h.v.u.s.p.q.r.txt == "j"