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

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

k = A("k")
e = B("e")
m = B("m")
n = B("n")
g = B("g")
b = A("b")
j = B("j")

k.s = j
k.t = j
e.r = b
e.s = b
m.r = k
m.s = k
n.r = b
n.s = k
g.r = k
g.s = k
b.s = m
b.t = j
j.r = b
j.s = b
assert k.s.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.t: B = None
        self.txt = txt

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

k = A("k")
e = B("e")
m = B("m")
n = B("n")
g = B("g")
b = A("b")
j = B("j")

k.s = j
k.t = j
e.r = b
e.s = b
m.r = k
m.s = k
n.r = b
n.s = k
g.r = k
g.s = k
b.s = m
b.t = j
j.r = b
j.s = b
assert k.s.r.t.txt == "j"