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

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

i = A("i")
b = B("b")
h = B("h")
j = A("j")
e = B("e")
f = B("f")

i.v = j
b.p = e
h.p = e
j.v = i
e.p = b
f.p = b
assert e.p.p.p.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

i = A("i")
b = B("b")
h = B("h")
j = A("j")
e = B("e")
f = B("f")

i.v = j
b.p = e
h.p = e
j.v = i
e.p = b
f.p = b
assert e.p.p.p.p.p.txt == "b"