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

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

i = A("i")
f = B("f")
c = B("c")
m = A("m")
d = B("d")
a = A("a")
g = A("g")

i.o = g
f.y = d
f.v = d
c.y = f
c.v = f
m.o = a
d.y = c
d.v = c
a.o = g
g.o = a
assert g.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

i = A("i")
f = B("f")
c = B("c")
m = A("m")
d = B("d")
a = A("a")
g = A("g")

i.o = g
f.y = d
f.v = d
c.y = f
c.v = f
m.o = a
d.y = c
d.v = c
a.o = g
g.o = a
assert g.o.o.o.txt == "a"