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

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

k = A("k")
g = B("g")
c = B("c")
f = A("f")
l = B("l")
j = B("j")

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

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

k = A("k")
g = B("g")
c = B("c")
f = A("f")
l = B("l")
j = B("j")

k.x = g
g.q = f
g.s = f
c.q = k
c.s = k
f.x = l
l.q = f
l.s = f
j.q = f
j.s = f
assert f.x.s.x.q.x.txt == "l"