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

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

i = A("i")
j = B("j")
a = A("a")
c = B("c")

i.y = a
i.z = a
j.o = i
a.y = i
a.z = i
c.o = a
assert c.o.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.txt = txt

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

i = A("i")
j = B("j")
a = A("a")
c = B("c")

i.y = a
i.z = a
j.o = i
a.y = i
a.z = i
c.o = a
assert c.o.z.z.txt == "a"