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

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

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

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

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

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

i.y = c
a.w = i
a.v = c
c.y = i
j.w = i
j.v = c
assert c.y.y.y.y.txt == "c"