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

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

c = A("c")
j = B("j")
b = A("b")
m = B("m")

c.u = m
c.r = j
j.u = m
j.y = m
b.u = m
b.r = j
m.u = j
m.y = j
assert b.r.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.r: B = None
        self.txt = txt

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

c = A("c")
j = B("j")
b = A("b")
m = B("m")

c.u = m
c.r = j
j.u = m
j.y = m
b.u = m
b.r = j
m.u = j
m.y = j
assert b.r.y.y.txt == "j"