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

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

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

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

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

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

b.v = k
k.s = c
k.t = c
c.s = k
c.t = k
g.v = k
d.v = k
assert g.v.s.t.s.txt == "c"