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

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

c = A("c")
g = B("g")
k = A("k")
e = B("e")
d = B("d")

c.s = e
g.o = d
k.s = e
e.o = d
d.o = g
assert g.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

c = A("c")
g = B("g")
k = A("k")
e = B("e")
d = B("d")

c.s = e
g.o = d
k.s = e
e.o = d
d.o = g
assert g.o.o.o.o.txt == "g"