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

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

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

f.y = j
f.u = j
g.t = k
g.s = f
k.t = g
k.s = f
j.y = f
j.u = f
n.t = k
n.s = j
assert g.s.u.u.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.u: A = None
        self.txt = txt

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

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

f.y = j
f.u = j
g.t = k
g.s = f
k.t = g
k.s = f
j.y = f
j.u = f
n.t = k
n.s = j
assert g.s.u.u.y.txt == "j"