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

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

e = A("e")
g = B("g")
k = B("k")
h = B("h")
f = B("f")
a = A("a")

e.v = a
g.x = k
k.x = h
h.x = k
f.x = h
a.v = e
assert g.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

e = A("e")
g = B("g")
k = B("k")
h = B("h")
f = B("f")
a = A("a")

e.v = a
g.x = k
k.x = h
h.x = k
f.x = h
a.v = e
assert g.x.x.x.x.x.txt == "k"