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

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

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

c.v = k
i.t = d
d.v = k
g.t = d
k.v = d
e.t = c
assert i.t.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

c.v = k
i.t = d
d.v = k
g.t = d
k.v = d
e.t = c
assert i.t.v.v.v.txt == "k"