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

d = A("d")
h = B("h")
b = B("b")
f = A("f")
k = B("k")
l = B("l")
m = B("m")
c = B("c")

d.v = f
h.t = d
b.t = d
f.v = d
k.t = f
l.t = f
m.t = f
c.t = d
assert l.t.v.v.v.v.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

d = A("d")
h = B("h")
b = B("b")
f = A("f")
k = B("k")
l = B("l")
m = B("m")
c = B("c")

d.v = f
h.t = d
b.t = d
f.v = d
k.t = f
l.t = f
m.t = f
c.t = d
assert l.t.v.v.v.v.v.v.v.txt == "d"