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

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

c = A("c")
i = B("i")
g = B("g")
b = B("b")
j = B("j")
f = B("f")

c.q = i
c.w = g
i.r = c
i.u = j
g.r = c
g.u = f
b.r = c
b.u = g
j.r = c
j.u = i
f.r = c
f.u = g
assert i.r.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.w: B = None
        self.txt = txt

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

c = A("c")
i = B("i")
g = B("g")
b = B("b")
j = B("j")
f = B("f")

c.q = i
c.w = g
i.r = c
i.u = j
g.r = c
g.u = f
b.r = c
b.u = g
j.r = c
j.u = i
f.r = c
f.u = g
assert i.r.q.u.txt == "j"