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

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

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

j.r = c
j.t = c
n.w = k
n.z = k
k.w = n
k.z = n
c.r = g
c.t = g
g.r = c
g.t = c
assert c.r.t.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: A = None
        self.txt = txt

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

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

j.r = c
j.t = c
n.w = k
n.z = k
k.w = n
k.z = n
c.r = g
c.t = g
g.r = c
g.t = c
assert c.r.t.r.r.r.txt == "g"