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

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

a = A("a")
b = B("b")
k = A("k")
g = B("g")
f = A("f")
d = B("d")

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

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

a = A("a")
b = B("b")
k = A("k")
g = B("g")
f = A("f")
d = B("d")

a.x = f
a.v = g
b.t = f
b.v = d
k.x = f
k.v = g
g.t = f
g.v = d
f.x = k
f.v = g
d.t = k
d.v = g
assert g.t.x.x.txt == "f"