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

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

l = A("l")
c = B("c")
m = B("m")
i = A("i")
g = B("g")
e = A("e")
f = A("f")

l.s = c
l.u = f
c.x = i
c.p = g
m.x = e
m.p = c
i.s = m
i.u = e
g.x = f
g.p = m
e.s = m
e.u = f
f.s = c
f.u = l
assert i.u.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.u: A = None
        self.txt = txt

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

l = A("l")
c = B("c")
m = B("m")
i = A("i")
g = B("g")
e = A("e")
f = A("f")

l.s = c
l.u = f
c.x = i
c.p = g
m.x = e
m.p = c
i.s = m
i.u = e
g.x = f
g.p = m
e.s = m
e.u = f
f.s = c
f.u = l
assert i.u.s.p.txt == "c"