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

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

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

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

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

j = A("j")
k = B("k")
c = C("c")
e = D("e")
f = E("f")
b = E("b")
g = D("g")

j.r = k
j.u = k
k.u = c
k.q = j
k.s = b
k.v = e
c.r = k
c.u = k
c.z = f
e.q = c
f.r = k
f.t = e
f.w = j
b.r = k
b.t = e
b.w = j
g.q = c
assert b.r.s.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.u: B = None
        self.txt = txt

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

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

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

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

j = A("j")
k = B("k")
c = C("c")
e = D("e")
f = E("f")
b = E("b")
g = D("g")

j.r = k
j.u = k
k.u = c
k.q = j
k.s = b
k.v = e
c.r = k
c.u = k
c.z = f
e.q = c
f.r = k
f.t = e
f.w = j
b.r = k
b.t = e
b.w = j
g.q = c
assert b.r.s.r.q.txt == "j"