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

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

f = A("f")
b = B("b")
n = B("n")
j = B("j")
l = B("l")
a = A("a")

f.r = n
b.y = j
n.y = b
j.y = n
l.y = j
a.r = n
assert f.r.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

f = A("f")
b = B("b")
n = B("n")
j = B("j")
l = B("l")
a = A("a")

f.r = n
b.y = j
n.y = b
j.y = n
l.y = j
a.r = n
assert f.r.y.y.y.y.txt == "b"