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

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

g = A("g")
j = B("j")
f = B("f")
e = A("e")

g.r = e
g.o = e
j.z = f
f.z = j
e.r = g
e.o = g
assert g.o.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.o: A = None
        self.txt = txt

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

g = A("g")
j = B("j")
f = B("f")
e = A("e")

g.r = e
g.o = e
j.z = f
f.z = j
e.r = g
e.o = g
assert g.o.r.o.r.txt == "g"