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

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

c = A("c")
a = B("a")
j = B("j")

c.p = a
c.y = a
a.v = j
a.x = j
j.v = a
j.x = a
assert a.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.y: B = None
        self.txt = txt

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

c = A("c")
a = B("a")
j = B("j")

c.p = a
c.y = a
a.v = j
a.x = j
j.v = a
j.x = a
assert a.v.v.v.txt == "j"