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

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

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

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

j = A("j")
c = B("c")
n = C("n")
l = D("l")
g = B("g")
d = D("d")

j.x = c
j.o = c
j.u = d
c.z = j
c.s = g
c.x = g
c.q = n
n.r = j
n.y = j
n.u = l
l.r = g
l.x = n
l.q = j
l.s = d
g.z = j
g.s = c
g.x = c
g.q = n
d.r = g
d.x = n
d.q = j
d.s = l
assert g.z.u.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: D = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
c = B("c")
n = C("n")
l = D("l")
g = B("g")
d = D("d")

j.x = c
j.o = c
j.u = d
c.z = j
c.s = g
c.x = g
c.q = n
n.r = j
n.y = j
n.u = l
l.r = g
l.x = n
l.q = j
l.s = d
g.z = j
g.s = c
g.x = c
g.q = n
d.r = g
d.x = n
d.q = j
d.s = l
assert g.z.u.s.q.txt == "j"