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

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

g = A("g")
k = B("k")
f = A("f")

g.r = k
g.t = k
k.y = f
f.r = k
f.t = k
assert f.r.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: B = None
        self.txt = txt

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

g = A("g")
k = B("k")
f = A("f")

g.r = k
g.t = k
k.y = f
f.r = k
f.t = k
assert f.r.y.t.txt == "k"