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

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

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

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

l = A("l")
g = B("g")
e = C("e")
n = D("n")
c = C("c")
b = D("b")
i = A("i")

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

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

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

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

l = A("l")
g = B("g")
e = C("e")
n = D("n")
c = C("c")
b = D("b")
i = A("i")

l.s = g
l.x = i
g.p = i
g.o = n
g.q = n
g.x = n
e.z = l
e.p = i
n.u = c
n.r = c
n.y = b
n.q = g
c.z = i
c.p = i
b.u = e
b.r = e
b.y = n
b.q = g
i.s = g
i.x = l
assert g.p.x.s.txt == "g"