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

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

c = A("c")
m = B("m")
l = B("l")
a = A("a")
n = B("n")
g = A("g")
k = B("k")
f = B("f")

c.y = k
c.s = g
m.x = g
l.x = a
a.y = f
a.s = g
n.x = a
g.y = l
g.s = a
k.x = c
f.x = c
assert c.y.x.s.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.s: A = None
        self.txt = txt

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

c = A("c")
m = B("m")
l = B("l")
a = A("a")
n = B("n")
g = A("g")
k = B("k")
f = B("f")

c.y = k
c.s = g
m.x = g
l.x = a
a.y = f
a.s = g
n.x = a
g.y = l
g.s = a
k.x = c
f.x = c
assert c.y.x.s.s.y.txt == "f"