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

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

i = A("i")
f = B("f")
h = A("h")
c = B("c")
g = B("g")
k = B("k")
j = B("j")

i.z = c
i.r = h
f.s = g
f.t = h
h.z = g
h.r = i
c.s = f
c.t = h
g.s = f
g.t = i
k.s = g
k.t = h
j.s = g
j.t = h
assert g.t.r.z.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: A = None
        self.txt = txt

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

i = A("i")
f = B("f")
h = A("h")
c = B("c")
g = B("g")
k = B("k")
j = B("j")

i.z = c
i.r = h
f.s = g
f.t = h
h.z = g
h.r = i
c.s = f
c.t = h
g.s = f
g.t = i
k.s = g
k.t = h
j.s = g
j.t = h
assert g.t.r.z.s.s.s.txt == "f"